From aca59bcde29fc149ac2c5ef07976b73c45a71d1a Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Fri, 1 Jul 2011 20:10:02 -0500 Subject: [PATCH] dev: reduce warnings --- lib/rspec/mocks.rb | 2 +- spec/rspec/mocks/any_number_of_times_spec.rb | 4 +- spec/rspec/mocks/at_least_spec.rb | 2 +- spec/rspec/mocks/at_most_spec.rb | 2 +- spec/rspec/mocks/bug_report_10263_spec.rb | 2 +- spec/rspec/mocks/bug_report_7611_spec.rb | 2 +- spec/rspec/mocks/bug_report_8165_spec.rb | 4 +- spec/rspec/mocks/bug_report_957_spec.rb | 4 +- .../mocks/failing_argument_matchers_spec.rb | 4 +- .../mocks/hash_including_matcher_spec.rb | 22 +++--- .../mocks/hash_not_including_matcher_spec.rb | 12 +-- spec/rspec/mocks/mock_spec.rb | 76 +++++++++---------- .../rspec/mocks/multiple_return_value_spec.rb | 52 ++++++------- spec/rspec/mocks/partial_mock_spec.rb | 5 +- .../partial_mock_using_mocks_directly_spec.rb | 1 + .../mocks/passing_argument_matchers_spec.rb | 6 +- spec/rspec/mocks/precise_counts_spec.rb | 2 +- spec/rspec/mocks/serialization_spec.rb | 2 +- spec/rspec/mocks/stub_implementation_spec.rb | 12 +-- spec/rspec/mocks/stub_spec.rb | 12 +-- 20 files changed, 112 insertions(+), 116 deletions(-) diff --git a/lib/rspec/mocks.rb b/lib/rspec/mocks.rb index 0bdd3436f..cb8c9ffbd 100644 --- a/lib/rspec/mocks.rb +++ b/lib/rspec/mocks.rb @@ -152,7 +152,7 @@ module RSpec # # double.should_receive(:msg) do |arg| # arg.should be_an_istance_of(Array) - # arg.length.should == 7 + # arg.length.should eq 7 # end # # == Combining Expectation Details diff --git a/spec/rspec/mocks/any_number_of_times_spec.rb b/spec/rspec/mocks/any_number_of_times_spec.rb index 3003cbfbf..9e2145d21 100644 --- a/spec/rspec/mocks/any_number_of_times_spec.rb +++ b/spec/rspec/mocks/any_number_of_times_spec.rb @@ -24,7 +24,7 @@ it "returns the mocked value when called after a similar stub" do @mock.stub(:message).and_return :stub_value @mock.should_receive(:message).any_number_of_times.and_return(:mock_value) - @mock.message.should == :mock_value - @mock.message.should == :mock_value + @mock.message.should eq :mock_value + @mock.message.should eq :mock_value end end diff --git a/spec/rspec/mocks/at_least_spec.rb b/spec/rspec/mocks/at_least_spec.rb index c70e7a4cc..7230f8979 100644 --- a/spec/rspec/mocks/at_least_spec.rb +++ b/spec/rspec/mocks/at_least_spec.rb @@ -95,7 +95,7 @@ module Mocks it "returns the value given by a block when the at least once method is called" do @mock.should_receive(:to_s).at_least(:once) { "testing" } - @mock.to_s.should == "testing" + @mock.to_s.should eq "testing" @mock.rspec_verify end end diff --git a/spec/rspec/mocks/at_most_spec.rb b/spec/rspec/mocks/at_most_spec.rb index 4581fd3ab..22bd5c9f8 100644 --- a/spec/rspec/mocks/at_most_spec.rb +++ b/spec/rspec/mocks/at_most_spec.rb @@ -91,7 +91,7 @@ module Mocks it "returns the value given by a block when the at most once method is called" do @mock.should_receive(:to_s).at_most(:once) { "testing" } - @mock.to_s.should == "testing" + @mock.to_s.should eq "testing" @mock.rspec_verify end end diff --git a/spec/rspec/mocks/bug_report_10263_spec.rb b/spec/rspec/mocks/bug_report_10263_spec.rb index bee5238c1..96f1a4a97 100644 --- a/spec/rspec/mocks/bug_report_10263_spec.rb +++ b/spec/rspec/mocks/bug_report_10263_spec.rb @@ -18,7 +18,7 @@ begin test_double.foobar rescue Exception => e - e.message.should == "Double received unexpected message :foobar with (no args)" + e.message.should eq "Double received unexpected message :foobar with (no args)" end end end diff --git a/spec/rspec/mocks/bug_report_7611_spec.rb b/spec/rspec/mocks/bug_report_7611_spec.rb index 652762695..77775e82f 100644 --- a/spec/rspec/mocks/bug_report_7611_spec.rb +++ b/spec/rspec/mocks/bug_report_7611_spec.rb @@ -10,7 +10,7 @@ class Bar < Foo; end end it "should" do - Bar.new.class.should == Bar + Bar.new.class.should eq Bar end end end diff --git a/spec/rspec/mocks/bug_report_8165_spec.rb b/spec/rspec/mocks/bug_report_8165_spec.rb index a864d4d17..6788151f1 100644 --- a/spec/rspec/mocks/bug_report_8165_spec.rb +++ b/spec/rspec/mocks/bug_report_8165_spec.rb @@ -17,7 +17,7 @@ obj.should_receive(:respond_to?).with(:foobar).and_return(true) obj.should_receive(:foobar).and_return(:baz) obj.respond_to?(:foobar).should be_true - obj.foobar.should == :baz + obj.foobar.should eq :baz end it "does not raise an exception for mock" do @@ -25,7 +25,7 @@ obj.should_receive(:respond_to?).with(:foobar).and_return(true) obj.should_receive(:foobar).and_return(:baz) obj.respond_to?(:foobar).should be_true - obj.foobar.should == :baz + obj.foobar.should eq :baz end end diff --git a/spec/rspec/mocks/bug_report_957_spec.rb b/spec/rspec/mocks/bug_report_957_spec.rb index b80dae9b6..2cfbcf817 100644 --- a/spec/rspec/mocks/bug_report_957_spec.rb +++ b/spec/rspec/mocks/bug_report_957_spec.rb @@ -11,11 +11,11 @@ module Mocks end it "returns the value for the stub on the base class" do - @base_class.find.should == "stubbed_value" + @base_class.find.should eq "stubbed_value" end it "returns the value for the descendent class" do - @concrete_class.find.should == "stubbed_value" + @concrete_class.find.should eq "stubbed_value" end end end diff --git a/spec/rspec/mocks/failing_argument_matchers_spec.rb b/spec/rspec/mocks/failing_argument_matchers_spec.rb index 51e379518..f2ce194f7 100644 --- a/spec/rspec/mocks/failing_argument_matchers_spec.rb +++ b/spec/rspec/mocks/failing_argument_matchers_spec.rb @@ -85,9 +85,9 @@ module Mocks it "fails with block matchers" do expect do - @double.should_receive(:msg).with {|arg| arg.should == :received } + @double.should_receive(:msg).with {|arg| arg.should eq :received } @double.msg :no_msg_for_you - end.to raise_error(RSpec::Expectations::ExpectationNotMetError, /expected: :received.*\s*.*got: :no_msg_for_you/) + end.to raise_error(RSpec::Expectations::ExpectationNotMetError, /expected :received.*\s*.*got :no_msg_for_you/) end end diff --git a/spec/rspec/mocks/hash_including_matcher_spec.rb b/spec/rspec/mocks/hash_including_matcher_spec.rb index 774028b59..caea728b4 100644 --- a/spec/rspec/mocks/hash_including_matcher_spec.rb +++ b/spec/rspec/mocks/hash_including_matcher_spec.rb @@ -6,51 +6,51 @@ module ArgumentMatchers describe HashIncludingMatcher do it "describes itself properly" do - HashIncludingMatcher.new(:a => 1).description.should == "hash_including(:a=>1)" + HashIncludingMatcher.new(:a => 1).description.should eq "hash_including(:a=>1)" end describe "passing" do it "matches the same hash" do - hash_including(:a => 1).should == {:a => 1} + hash_including(:a => 1).should eq({:a => 1}) end it "matches a hash with extra stuff" do - hash_including(:a => 1).should == {:a => 1, :b => 2} + hash_including(:a => 1).should eq({:a => 1, :b => 2}) end describe "when matching against other matchers" do it "matches an int against anything()" do - hash_including(:a => anything, :b => 2).should == {:a => 1, :b => 2} + hash_including(:a => anything, :b => 2).should eq({:a => 1, :b => 2}) end it "matches a string against anything()" do - hash_including(:a => anything, :b => 2).should == {:a => "1", :b => 2} + hash_including(:a => anything, :b => 2).should eq({:a => "1", :b => 2}) end end describe "when passed only keys or keys mixed with key/value pairs" do it "matches if the key is present" do - hash_including(:a).should == {:a => 1, :b => 2} + hash_including(:a).should eq({:a => 1, :b => 2}) end it "matches if more keys are present" do - hash_including(:a, :b).should == {:a => 1, :b => 2, :c => 3} + hash_including(:a, :b).should eq({:a => 1, :b => 2, :c => 3}) end it "matches a string against a given key" do - hash_including(:a).should == {:a => "1", :b => 2} + hash_including(:a).should eq({:a => "1", :b => 2}) end it "matches if passed one key and one key/value pair" do - hash_including(:a, :b => 2).should == {:a => 1, :b => 2} + hash_including(:a, :b => 2).should eq({:a => 1, :b => 2}) end it "matches if passed many keys and one key/value pair" do - hash_including(:a, :b, :c => 3).should == {:a => 1, :b => 2, :c => 3, :d => 4} + hash_including(:a, :b, :c => 3).should eq({:a => 1, :b => 2, :c => 3, :d => 4}) end it "matches if passed many keys and many key/value pairs" do - hash_including(:a, :b, :c => 3, :e => 5).should == {:a => 1, :b => 2, :c => 3, :d => 4, :e => 5} + hash_including(:a, :b, :c => 3, :e => 5).should eq({:a => 1, :b => 2, :c => 3, :d => 4, :e => 5}) end end end diff --git a/spec/rspec/mocks/hash_not_including_matcher_spec.rb b/spec/rspec/mocks/hash_not_including_matcher_spec.rb index ad85084b8..51b842faa 100644 --- a/spec/rspec/mocks/hash_not_including_matcher_spec.rb +++ b/spec/rspec/mocks/hash_not_including_matcher_spec.rb @@ -6,28 +6,28 @@ module ArgumentMatchers describe HashNotIncludingMatcher do it "describes itself properly" do - HashNotIncludingMatcher.new(:a => 5).description.should == "hash_not_including(:a=>5)" + HashNotIncludingMatcher.new(:a => 5).description.should eq "hash_not_including(:a=>5)" end describe "passing" do it "matches a hash without the specified key" do - hash_not_including(:c).should == {:a => 1, :b => 2} + hash_not_including(:c).should eq({:a => 1, :b => 2}) end it "matches a hash with the specified key, but different value" do - hash_not_including(:b => 3).should == {:a => 1, :b => 2} + hash_not_including(:b => 3).should eq({:a => 1, :b => 2}) end it "matches a hash without the specified key, given as anything()" do - hash_not_including(:c => anything).should == {:a => 1, :b => 2} + hash_not_including(:c => anything).should eq({:a => 1, :b => 2}) end it "matches an empty hash" do - hash_not_including(:a).should == {} + hash_not_including(:a).should eq({}) end it "matches a hash without any of the specified keys" do - hash_not_including(:a, :b, :c).should == { :d => 7} + hash_not_including(:a, :b, :c).should eq({ :d => 7}) end end diff --git a/spec/rspec/mocks/mock_spec.rb b/spec/rspec/mocks/mock_spec.rb index edf1878c0..4d73f7b8e 100644 --- a/spec/rspec/mocks/mock_spec.rb +++ b/spec/rspec/mocks/mock_spec.rb @@ -78,20 +78,20 @@ module Mocks it "allows block to calculate return values" do @mock.should_receive(:something).with("a","b","c").and_return { |a,b,c| c+b+a } - @mock.something("a","b","c").should == "cba" + @mock.something("a","b","c").should eq "cba" @mock.rspec_verify end it "allows parameter as return value" do @mock.should_receive(:something).with("a","b","c").and_return("booh") - @mock.something("a","b","c").should == "booh" + @mock.something("a","b","c").should eq "booh" @mock.rspec_verify end it "returns the previously stubbed value if no return value is set" do @mock.stub(:something).with("a","b","c").and_return(:stubbed_value) @mock.should_receive(:something).with("a","b","c") - @mock.something("a","b","c").should == :stubbed_value + @mock.something("a","b","c").should eq :stubbed_value @mock.rspec_verify end @@ -159,11 +159,11 @@ def @mock.method_with_default_argument(arg={}); end it "uses block for expectation if provided" do @mock.should_receive(:something) do | a, b | - a.should == "a" - b.should == "b" + a.should eq "a" + b.should eq "b" "booh" end - @mock.something("a", "b").should == "booh" + @mock.something("a", "b").should eq "booh" @mock.rspec_verify end @@ -181,8 +181,8 @@ def @mock.method_with_default_argument(arg={}); end eval("@mock.should_receive(:something) { |&block| a = block }") b = lambda { } @mock.something(&b) - a.should == b - @moc.rspec_verify + a.should eq b + @mock.rspec_verify end it "fails right away when method defined as never is received" do @@ -270,7 +270,7 @@ def @mock.method_with_default_argument(arg={}); end it "returns value from block by default" do @mock.stub(:method_that_yields).and_yield - @mock.method_that_yields { :returned_obj }.should == :returned_obj + @mock.method_that_yields { :returned_obj }.should eq :returned_obj @mock.rspec_verify end @@ -278,17 +278,16 @@ def @mock.method_with_default_argument(arg={}); end @mock.should_receive(:yield_back).with(no_args()).once.and_yield a = nil @mock.yield_back {|*x| a = x} - a.should == [] + a.should eq [] @mock.rspec_verify end it "yields 0 args multiple times to blocks that take a variable number of arguments" do @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield. and_yield - a = nil b = [] @mock.yield_back {|*a| b << a} - b.should == [ [], [] ] + b.should eq [ [], [] ] @mock.rspec_verify end @@ -296,7 +295,7 @@ def @mock.method_with_default_argument(arg={}); end @mock.should_receive(:yield_back).with(no_args()).once.and_yield(99) a = nil @mock.yield_back {|*x| a = x} - a.should == [99] + a.should eq [99] @mock.rspec_verify end @@ -304,10 +303,9 @@ def @mock.method_with_default_argument(arg={}); end @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield(99). and_yield(43). and_yield("something fruity") - a = nil b = [] @mock.yield_back {|*a| b << a} - b.should == [[99], [43], ["something fruity"]] + b.should eq [[99], [43], ["something fruity"]] @mock.rspec_verify end @@ -315,7 +313,7 @@ def @mock.method_with_default_argument(arg={}); end @mock.should_receive(:yield_back).with(no_args()).once.and_yield(99, 27, "go") a = nil @mock.yield_back {|*x| a = x} - a.should == [99, 27, "go"] + a.should eq [99, 27, "go"] @mock.rspec_verify end @@ -323,10 +321,9 @@ def @mock.method_with_default_argument(arg={}); end @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield(99, :green, "go"). and_yield("wait", :amber). and_yield("stop", 12, :red) - a = nil b = [] @mock.yield_back {|*a| b << a} - b.should == [[99, :green, "go"], ["wait", :amber], ["stop", 12, :red]] + b.should eq [[99, :green, "go"], ["wait", :amber], ["stop", 12, :red]] @mock.rspec_verify end @@ -334,7 +331,7 @@ def @mock.method_with_default_argument(arg={}); end @mock.should_receive(:yield_back).with(no_args()).once.and_yield(99) a = nil @mock.yield_back {|x| a = x} - a.should == 99 + a.should eq 99 @mock.rspec_verify end @@ -342,10 +339,9 @@ def @mock.method_with_default_argument(arg={}); end @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield(99). and_yield(43). and_yield("something fruity") - a = nil b = [] @mock.yield_back {|a| b << a} - b.should == [99, 43, "something fruity"] + b.should eq [99, 43, "something fruity"] @mock.rspec_verify end @@ -353,8 +349,8 @@ def @mock.method_with_default_argument(arg={}); end @mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup') a, b = nil @mock.yield_back {|x,y| a=x; b=y} - a.should == 'wha' - b.should == 'zup' + a.should eq 'wha' + b.should eq 'zup' @mock.rspec_verify end @@ -362,10 +358,9 @@ def @mock.method_with_default_argument(arg={}); end @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield('wha', 'zup'). and_yield('not', 'down'). and_yield(14, 65) - a, b = nil c = [] @mock.yield_back {|a,b| c << [a, b]} - c.should == [['wha', 'zup'], ['not', 'down'], [14, 65]] + c.should eq [['wha', 'zup'], ['not', 'down'], [14, 65]] @mock.rspec_verify end @@ -381,7 +376,6 @@ def @mock.method_with_default_argument(arg={}); end and_yield('down'). and_yield(14, 65) lambda { - a, b = nil c = [] @mock.yield_back {|a,b| c << [a, b]} }.should raise_error(RSpec::Mocks::MockExpectationError, "Double \"test double\" yielded |\"down\"| to block with arity of 2") @@ -508,8 +502,8 @@ def @mock.method_with_default_argument(arg={}); end it "does not mess with the stub's yielded values when also mocked" do @mock.stub(:yield_back).and_yield(:stub_value) @mock.should_receive(:yield_back).and_yield(:mock_value) - @mock.yield_back{|v| v.should == :mock_value } - @mock.yield_back{|v| v.should == :stub_value } + @mock.yield_back{|v| v.should eq :mock_value } + @mock.yield_back{|v| v.should eq :stub_value } @mock.rspec_verify end @@ -518,14 +512,14 @@ def @mock.method_with_default_argument(arg={}); end File.should_receive(:open).and_yield(:first_call).and_yield(:second_call) yielded_args = [] File.open {|v| yielded_args << v } - yielded_args.should == [:first_call, :second_call] - File.open {|v| v.should == :stub_value } + yielded_args.should eq [:first_call, :second_call] + File.open {|v| v.should eq :stub_value } File.rspec_verify end it "assigns stub return values" do mock = RSpec::Mocks::Mock.new('name', :message => :response) - mock.message.should == :response + mock.message.should eq :response end end @@ -545,7 +539,7 @@ def add_call @mock.foo - @calls.should == 1 + @calls.should eq 1 end it "calls the block after #should_receive after a similar stub" do @@ -554,7 +548,7 @@ def add_call @mock.foo - @calls.should == 1 + @calls.should eq 1 end it "calls the block after #once" do @@ -562,7 +556,7 @@ def add_call @mock.foo - @calls.should == 1 + @calls.should eq 1 end it "calls the block after #twice" do @@ -571,7 +565,7 @@ def add_call @mock.foo @mock.foo - @calls.should == 2 + @calls.should eq 2 end it "calls the block after #times" do @@ -579,7 +573,7 @@ def add_call (1..10).each { @mock.foo } - @calls.should == 10 + @calls.should eq 10 end it "calls the block after #any_number_of_times" do @@ -587,7 +581,7 @@ def add_call (1..7).each { @mock.foo } - @calls.should == 7 + @calls.should eq 7 end it "calls the block after #ordered" do @@ -597,7 +591,7 @@ def add_call @mock.foo @mock.bar - @calls.should == 2 + @calls.should eq 2 end end @@ -612,7 +606,7 @@ def add_call describe "string representation generated by #to_str" do it "looks the same as #to_s" do double = double("Foo") - double.to_str.should == double.to_s + double.to_str.should eq double.to_s end end @@ -624,8 +618,8 @@ def add_call it "does respond to initially stubbed methods" do double = double(:foo => "woo", :bar => "car") - double.foo.should == "woo" - double.bar.should == "car" + double.foo.should eq "woo" + double.bar.should eq "car" end end diff --git a/spec/rspec/mocks/multiple_return_value_spec.rb b/spec/rspec/mocks/multiple_return_value_spec.rb index 548b84ae7..aded1ff57 100644 --- a/spec/rspec/mocks/multiple_return_value_spec.rb +++ b/spec/rspec/mocks/multiple_return_value_spec.rb @@ -10,15 +10,15 @@ module Mocks end it "returns values in order to consecutive calls" do - @mock.message.should == @return_values[0] - @mock.message.should == @return_values[1] - @mock.message.should == @return_values[2] + @mock.message.should eq @return_values[0] + @mock.message.should eq @return_values[1] + @mock.message.should eq @return_values[2] @mock.rspec_verify end it "complains when there are too few calls" do - @mock.message.should == @return_values[0] - @mock.message.should == @return_values[1] + @mock.message.should eq @return_values[0] + @mock.message.should eq @return_values[1] expect { @mock.rspec_verify }.to raise_error( RSpec::Mocks::MockExpectationError, %Q|(Mock "mock").message(any args)\n expected: 3 times\n received: 2 times| @@ -26,10 +26,10 @@ module Mocks end it "complains when there are too many calls" do - @mock.message.should == @return_values[0] - @mock.message.should == @return_values[1] - @mock.message.should == @return_values[2] - @mock.message.should == @return_values[2] + @mock.message.should eq @return_values[0] + @mock.message.should eq @return_values[1] + @mock.message.should eq @return_values[2] + @mock.message.should eq @return_values[2] expect { @mock.rspec_verify }.to raise_error( RSpec::Mocks::MockExpectationError, %Q|(Mock "mock").message(any args)\n expected: 3 times\n received: 4 times| @@ -38,10 +38,10 @@ module Mocks it "doesn't complain when there are too many calls but method is stubbed too" do @mock.stub(:message).and_return :stub_result - @mock.message.should == @return_values[0] - @mock.message.should == @return_values[1] - @mock.message.should == @return_values[2] - @mock.message.should == :stub_result + @mock.message.should eq @return_values[0] + @mock.message.should eq @return_values[1] + @mock.message.should eq @return_values[2] + @mock.message.should eq :stub_result expect { @mock.rspec_verify }.to_not raise_error(RSpec::Mocks::MockExpectationError) end end @@ -54,16 +54,16 @@ module Mocks end it "returns values in order to consecutive calls" do - @mock.message.should == @return_values[0] - @mock.message.should == @return_values[1] - @mock.message.should == @return_values[2] + @mock.message.should eq @return_values[0] + @mock.message.should eq @return_values[1] + @mock.message.should eq @return_values[2] @mock.rspec_verify end it "complains when there are too few calls" do third = Object.new - @mock.message.should == @return_values[0] - @mock.message.should == @return_values[1] + @mock.message.should eq @return_values[0] + @mock.message.should eq @return_values[1] expect { @mock.rspec_verify }.to raise_error( RSpec::Mocks::MockExpectationError, %Q|(Mock "mock").message(any args)\n expected: 3 times\n received: 2 times| @@ -72,10 +72,10 @@ module Mocks it "complains when there are too many calls" do third = Object.new - @mock.message.should == @return_values[0] - @mock.message.should == @return_values[1] - @mock.message.should == @return_values[2] - @mock.message.should == @return_values[2] + @mock.message.should eq @return_values[0] + @mock.message.should eq @return_values[1] + @mock.message.should eq @return_values[2] + @mock.message.should eq @return_values[2] expect { @mock.rspec_verify }.to raise_error( RSpec::Mocks::MockExpectationError, %Q|(Mock "mock").message(any args)\n expected: 3 times\n received: 4 times| @@ -85,10 +85,10 @@ module Mocks it "complains when there are too many calls and method is stubbed too" do third = Object.new @mock.stub(:message).and_return :stub_result - @mock.message.should == @return_values[0] - @mock.message.should == @return_values[1] - @mock.message.should == @return_values[2] - @mock.message.should == :stub_result + @mock.message.should eq @return_values[0] + @mock.message.should eq @return_values[1] + @mock.message.should eq @return_values[2] + @mock.message.should eq :stub_result expect { @mock.rspec_verify }.to raise_error( RSpec::Mocks::MockExpectationError, %Q|(Mock "mock").message(any args)\n expected: 3 times\n received: 4 times| diff --git a/spec/rspec/mocks/partial_mock_spec.rb b/spec/rspec/mocks/partial_mock_spec.rb index 6aed982f9..1e5aa5bef 100644 --- a/spec/rspec/mocks/partial_mock_spec.rb +++ b/spec/rspec/mocks/partial_mock_spec.rb @@ -84,9 +84,10 @@ module Mocks it "uses reports nil in the error message" do allow_message_expectations_on_nil - @this_will_resolve_to_nil.should_receive(:foobar) + @nil = nil + @nil.should_receive(:foobar) expect { - @this_will_resolve_to_nil.rspec_verify + @nil.rspec_verify }.to raise_error( RSpec::Mocks::MockExpectationError, %Q|(nil).foobar(any args)\n expected: 1 time\n received: 0 times| diff --git a/spec/rspec/mocks/partial_mock_using_mocks_directly_spec.rb b/spec/rspec/mocks/partial_mock_using_mocks_directly_spec.rb index 380514b0e..d55c02bb1 100644 --- a/spec/rspec/mocks/partial_mock_using_mocks_directly_spec.rb +++ b/spec/rspec/mocks/partial_mock_using_mocks_directly_spec.rb @@ -5,6 +5,7 @@ module RSpec::Mocks let(:klass) do Class.new do module MethodMissing + remove_method :method_missing rescue nil def method_missing(m, *a, &b) if m == :captured_by_method_missing "response generated by method missing" diff --git a/spec/rspec/mocks/passing_argument_matchers_spec.rb b/spec/rspec/mocks/passing_argument_matchers_spec.rb index 4a644dba6..686497c53 100644 --- a/spec/rspec/mocks/passing_argument_matchers_spec.rb +++ b/spec/rspec/mocks/passing_argument_matchers_spec.rb @@ -87,11 +87,11 @@ module Mocks context "handling block matchers" do it "matches arguments against RSpec expectations" do @double.should_receive(:random_call).with {|arg1, arg2, arr, *rest| - arg1.should == 5 + arg1.should eq 5 arg2.should have_at_least(3).characters arg2.should have_at_most(10).characters - arr.map {|i| i * 2}.should == [2,4,6] - rest.should == [:fee, "fi", 4] + arr.map {|i| i * 2}.should eq [2,4,6] + rest.should eq [:fee, "fi", 4] } @double.random_call 5, "hello", [1,2,3], :fee, "fi", 4 end diff --git a/spec/rspec/mocks/precise_counts_spec.rb b/spec/rspec/mocks/precise_counts_spec.rb index 930e8fd2d..5973b2371 100644 --- a/spec/rspec/mocks/precise_counts_spec.rb +++ b/spec/rspec/mocks/precise_counts_spec.rb @@ -33,7 +33,7 @@ module Mocks it "returns the value given by a block when the exactly once method is called" do @mock.should_receive(:to_s).exactly(:once) { "testing" } - @mock.to_s.should == "testing" + @mock.to_s.should eq "testing" @mock.rspec_verify end diff --git a/spec/rspec/mocks/serialization_spec.rb b/spec/rspec/mocks/serialization_spec.rb index 484665f29..cad45ebe3 100644 --- a/spec/rspec/mocks/serialization_spec.rb +++ b/spec/rspec/mocks/serialization_spec.rb @@ -103,7 +103,7 @@ def set_stub it 'does not interfere with its marshalling' do marshalled_copy = Marshal.load(Marshal.dump(subject)) - marshalled_copy.should == subject + marshalled_copy.should eq subject end end end diff --git a/spec/rspec/mocks/stub_implementation_spec.rb b/spec/rspec/mocks/stub_implementation_spec.rb index 93722d89a..73874c282 100644 --- a/spec/rspec/mocks/stub_implementation_spec.rb +++ b/spec/rspec/mocks/stub_implementation_spec.rb @@ -7,7 +7,7 @@ module Mocks it "execs the block when called" do obj = stub() obj.stub(:foo) { :bar } - obj.foo.should == :bar + obj.foo.should eq :bar end end @@ -15,7 +15,7 @@ module Mocks it "execs the block with that arg when called" do obj = stub() obj.stub(:foo) {|given| given} - obj.foo(:bar).should == :bar + obj.foo(:bar).should eq :bar end end @@ -23,7 +23,7 @@ module Mocks it "execs the block when called" do obj = stub() obj.stub(:foo) {|*given| given.first} - obj.foo(:bar).should == :bar + obj.foo(:bar).should eq :bar end end end @@ -35,7 +35,7 @@ module Mocks def obj.foo; :original; end obj.stub(:foo) obj.unstub(:foo) - obj.foo.should == :original + obj.foo.should eq :original end it "removes all stubs with the supplied method name" do @@ -44,7 +44,7 @@ def obj.foo; :original; end obj.stub(:foo).with(1) obj.stub(:foo).with(2) obj.unstub(:foo) - obj.foo.should == :original + obj.foo.should eq :original end it "does not remove any expectations with the same method name" do @@ -54,7 +54,7 @@ def obj.foo; :original; end obj.stub(:foo).with(1) obj.stub(:foo).with(2) obj.unstub(:foo) - obj.foo(3).should == :three + obj.foo(3).should eq :three end it "raises a MockExpectationError if the method has not been stubbed" do diff --git a/spec/rspec/mocks/stub_spec.rb b/spec/rspec/mocks/stub_spec.rb index db4112d6f..697eeda25 100644 --- a/spec/rspec/mocks/stub_spec.rb +++ b/spec/rspec/mocks/stub_spec.rb @@ -134,7 +134,7 @@ def existing_private_instance_method @instance.stub(:method_that_yields).and_yield(:yielded_obj) current_value = :value_before @instance.method_that_yields {|val| current_value = val} - current_value.should == :yielded_obj + current_value.should eq :yielded_obj @instance.rspec_verify end @@ -143,7 +143,7 @@ def existing_private_instance_method and_yield(:another_value) current_value = [] @instance.method_that_yields_multiple_times {|val| current_value << val} - current_value.should == [:yielded_value, :another_value] + current_value.should eq [:yielded_value, :another_value] @instance.rspec_verify end @@ -151,7 +151,7 @@ def existing_private_instance_method yielded_obj = double("my mock") yielded_obj.should_receive(:foo).with(:bar) @instance.stub(:method_that_yields_and_returns).and_yield(yielded_obj).and_return(:baz) - @instance.method_that_yields_and_returns { |o| o.foo :bar }.should == :baz + @instance.method_that_yields_and_returns { |o| o.foo :bar }.should eq :baz end it "throws when told to" do @@ -163,13 +163,13 @@ def existing_private_instance_method it "overrides a pre-existing method" do @stub.stub(:existing_instance_method).and_return(:updated_stub_value) - @stub.existing_instance_method.should == :updated_stub_value + @stub.existing_instance_method.should eq :updated_stub_value end it "overrides a pre-existing stub" do @stub.stub(:foo) { 'bar' } @stub.stub(:foo) { 'baz' } - @stub.foo.should == 'baz' + @stub.foo.should eq 'baz' end it "allows a stub and an expectation" do @@ -181,7 +181,7 @@ def existing_private_instance_method it "calculates return value by executing block passed to #and_return" do @stub.stub(:something).with("a","b","c").and_return { |a,b,c| c+b+a } - @stub.something("a","b","c").should == "cba" + @stub.something("a","b","c").should eq "cba" @stub.rspec_verify end end