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.

See also: #assert_silent


206
207
208
209
210
211
212
213
214
215
# File 'lib/minitest/unit.rb', line 206

def assert_output stdout = nil, stderr = nil
  out, err = capture_io do
    yield
  end

  x = assert_equal stdout, out, "In stdout" if stdout
  y = assert_equal stderr, err, "In stderr" if stderr

  (!stdout || x) && (!stderr || y)
end