Method: MiniTest::Assertions#assert_output
- Defined in:
- lib/minitest/unit.rb
#assert_output(stdout = nil, stderr = nil) ⇒ Object
Fails if stdout or stderr do not output the expected results. Pass in nil if you don’t care about that streams output. Pass in “” if you require it to be silent. Pass in a regexp if you want to pattern match.
NOTE: this uses #capture_io, not #capture_subprocess_io.
See also: #assert_silent
326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/minitest/unit.rb', line 326 def assert_output stdout = nil, stderr = nil out, err = capture_io do yield end err_msg = Regexp === stderr ? :assert_match : :assert_equal if stderr out_msg = Regexp === stdout ? :assert_match : :assert_equal if stdout y = send err_msg, stderr, err, "In stderr" if err_msg x = send out_msg, stdout, out, "In stdout" if out_msg (!stdout || x) && (!stderr || y) end |