From d55cd34ba8680310fb07c2f5c1c6a27b4902865d Mon Sep 17 00:00:00 2001 From: eregon Date: Thu, 29 Jun 2017 14:35:09 +0000 Subject: Update to ruby/mspec@021a119 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/mspec/spec/matchers/output_to_fd_spec.rb | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'spec/mspec/spec/matchers/output_to_fd_spec.rb') diff --git a/spec/mspec/spec/matchers/output_to_fd_spec.rb b/spec/mspec/spec/matchers/output_to_fd_spec.rb index d35da58829..e584c4e003 100644 --- a/spec/mspec/spec/matchers/output_to_fd_spec.rb +++ b/spec/mspec/spec/matchers/output_to_fd_spec.rb @@ -5,38 +5,40 @@ require 'mspec/matchers' describe OutputToFDMatcher do # Figure out how in the hell to achieve this it "matches when running the block produces the expected output to the given FD" do - output_to_fd("Hi\n", STDERR).matches?(lambda { $stderr.print "Hi\n" }).should == true + OutputToFDMatcher.new("Hi\n", STDERR).matches?(lambda { $stderr.print "Hi\n" }).should == true end it "does not match if running the block does not produce the expected output to the FD" do - output_to_fd("Hi\n", STDERR).matches?(lambda { $stderr.puts("Hello\n") }).should == false + OutputToFDMatcher.new("Hi\n", STDERR).matches?(lambda { $stderr.puts("Hello\n") }).should == false end it "propagate the exception if one is thrown while matching" do exc = RuntimeError.new("propagates") lambda { - output_to_fd("Hi\n", STDERR).matches?(lambda { + OutputToFDMatcher.new("Hi\n", STDERR).matches?(lambda { raise exc }).should == false }.should raise_error(exc) end it "defaults to matching against STDOUT" do - output_to_fd("Hi\n").matches?(lambda { $stdout.print "Hi\n" }).should == true + object = Object.new + object.extend MSpecMatchers + object.send(:output_to_fd, "Hi\n").matches?(lambda { $stdout.print "Hi\n" }).should == true end it "accepts any IO instance" do io = IO.new STDOUT.fileno - output_to_fd("Hi\n", io).matches?(lambda { io.print "Hi\n" }).should == true + OutputToFDMatcher.new("Hi\n", io).matches?(lambda { io.print "Hi\n" }).should == true end it "allows matching with a Regexp" do s = "Hi there\n" - output_to_fd(/Hi/, STDERR).matches?(lambda { $stderr.print s }).should == true - output_to_fd(/Hi?/, STDERR).matches?(lambda { $stderr.print s }).should == true - output_to_fd(/[hH]i?/, STDERR).matches?(lambda { $stderr.print s }).should == true - output_to_fd(/.*/, STDERR).matches?(lambda { $stderr.print s }).should == true - output_to_fd(/H.*?here/, STDERR).matches?(lambda { $stderr.print s }).should == true - output_to_fd(/Ahoy/, STDERR).matches?(lambda { $stderr.print s }).should == false + OutputToFDMatcher.new(/Hi/, STDERR).matches?(lambda { $stderr.print s }).should == true + OutputToFDMatcher.new(/Hi?/, STDERR).matches?(lambda { $stderr.print s }).should == true + OutputToFDMatcher.new(/[hH]i?/, STDERR).matches?(lambda { $stderr.print s }).should == true + OutputToFDMatcher.new(/.*/, STDERR).matches?(lambda { $stderr.print s }).should == true + OutputToFDMatcher.new(/H.*?here/, STDERR).matches?(lambda { $stderr.print s }).should == true + OutputToFDMatcher.new(/Ahoy/, STDERR).matches?(lambda { $stderr.print s }).should == false end end -- cgit v1.2.3