Method: RSpec::Matchers#output
- Defined in:
- lib/rspec/matchers.rb
#output(expected = nil) ⇒ Object Also known as: a_block_outputting
to_stdout and to_stderr work by temporarily replacing $stdout or $stderr,
so they're not able to intercept stream output that explicitly uses STDOUT/STDERR
or that uses a reference to $stdout/$stderr that was stored before the
matcher was used.
to_stdout_from_any_process and to_stderr_from_any_process use Tempfiles, and
are thus significantly (~30x) slower than to_stdout and to_stderr.
With no arg, passes if the block outputs to_stdout or to_stderr.
With a string, passes if the block outputs that specific string to_stdout or to_stderr.
With a regexp or matcher, passes if the block outputs a string to_stdout or to_stderr that matches.
To capture output from any spawned subprocess as well, use to_stdout_from_any_process or
to_stderr_from_any_process. Output from any process that inherits the main process's corresponding
standard stream will be captured.
752 753 754 |
# File 'lib/rspec/matchers.rb', line 752 def output(expected=nil) BuiltIn::Output.new(expected) end |