Ruby minitest assert_output syntax

前端 未结 1 852
粉色の甜心
粉色の甜心 2021-01-12 00:44

I am new to minitest and still new to ruby and really tired of trying to google this question without result. I would be really grateful for help:

What is the exact

相关标签:
1条回答
  • 2021-01-12 01:26

    In order for your test method to run, the method name needs to start with test_. Also, the way assert_output works is that the block will write to stdout/stderr, and the arguments will be checked if they match stdout/stderr. The easiest way to check this IMO is to pass in a regexp. So this is how I would write that test:

    class TestTestClass < MiniTest::Unit::TestCase 
      def setup
        @test = TestClass.new
      end
    
      def test_output_produces_output
        assert_output(/hey/) { @test.output}
      end   
    end 
    
    0 讨论(0)
提交回复
热议问题