Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
output matcher: add a couple of extra tests
Browse files Browse the repository at this point in the history
* Error out when using it with *_from_any_process
* Chain matchers
  • Loading branch information
porras committed May 16, 2024
1 parent ecd9c1c commit e88c786
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions spec/rspec/matchers/built_in/output_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ def print_to_stream(msg)
expect { print "foo" }.to output("foo").as_tty # <- wrong call, `to_std(out|err)` is missing
}.to raise_error(/can only be used with `to_stdout` or `to_stderr`/)
end

it "errors out nicely when attempting it with *_from_any_process" do
expect {
expect { print "foo" }.to output("foo").to_stdout_from_any_process.as_tty
}.to raise_error(/can only be used with `to_stdout` or `to_stderr`/)
end

it "can be chained" do
expect { print "foo" if $stdout.tty?; $stderr.print "bar" if $stderr.tty? }.
to output("foo").to_stdout.as_tty.
and output("bar").to_stderr.as_tty
end
end
end
end

0 comments on commit e88c786

Please sign in to comment.