Skip to content

Commit

Permalink
Add a spec for rspec#1406
Browse files Browse the repository at this point in the history
  • Loading branch information
pirj authored and henrahmagix committed Dec 17, 2023
1 parent 121b580 commit 1212192
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/rspec/matchers/built_in/output_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,26 @@ def print_to_stream(msg)
expect(output("foo").description).to eq('output "foo" to some stream')
end
end

RSpec.describe "can capture stdin and stderr" do
it "prints diff for both when both fail" do
expect {
expect { print "foo"; $stderr.print("bar") }
.to output(/baz/).to_stdout
.and output(/qux/).to_stderr
}
.to fail_including(
'expected block to output /baz/ to stdout, but output "foo"',
'...and:',
'expected block to output /qux/ to stderr, but output "bar"',
'Diff for (output /baz/ to stdout):',
'-/baz/',
'+"foo"',
'Diff for (output /qux/ to stderr):',
'-/qux/',
'+"bar"'
)
end
end
end
end

0 comments on commit 1212192

Please sign in to comment.