spec/rspec/mocks/any_instance_spec.rb in rspec-mocks-2.11.3 vs spec/rspec/mocks/any_instance_spec.rb in rspec-mocks-2.12.0

- old
+ new

@@ -271,41 +271,41 @@ lambda do klass.any_instance.unstub(:existing_method) end.should raise_error(RSpec::Mocks::MockExpectationError, 'The method `existing_method` was not stubbed or was already unstubbed') end end - + context "with #should_not_receive" do it "fails if the method is called" do klass.any_instance.should_not_receive(:existing_method) lambda { klass.new.existing_method }.should raise_error(RSpec::Mocks::MockExpectationError) end - + it "passes if no method is called" do lambda { klass.any_instance.should_not_receive(:existing_method) }.should_not raise_error end - + it "passes if only a different method is called" do klass.any_instance.should_not_receive(:existing_method) lambda { klass.new.another_existing_method }.should_not raise_error end - + context "with constraints" do it "fails if the method is called with the specified parameters" do klass.any_instance.should_not_receive(:existing_method_with_arguments).with(:argument_one, :argument_two) lambda do - klass.new.existing_method_with_arguments(:argument_one, :argument_two) + klass.new.existing_method_with_arguments(:argument_one, :argument_two) end.should raise_error(RSpec::Mocks::MockExpectationError) end - + it "passes if the method is called with different parameters" do klass.any_instance.should_not_receive(:existing_method_with_arguments).with(:argument_one, :argument_two) lambda { klass.new.existing_method_with_arguments(:argument_three, :argument_four) }.should_not raise_error end end end - + context "with #should_receive" do let(:foo_expectation_error_message) { 'Exactly one instance should have received the following message(s) but didn\'t: foo' } let(:existing_method_expectation_error_message) { 'Exactly one instance should have received the following message(s) but didn\'t: existing_method' } context "with an expectation is set on a method which does not exist" do @@ -822,9 +822,20 @@ it "doesn't bomb if the object doesn't support `dup`" do klass = Class.new do undef_method :dup end klass.any_instance + end + + it "doesn't fail when dup accepts parameters" do + klass = Class.new do + def dup(funky_option) + end + end + + klass.any_instance + + lambda { klass.new.dup('Dup dup dup') }.should_not raise_error(ArgumentError) end end context "when directed at a method defined on a superclass" do let(:sub_klass) { Class.new(klass) }