Skip to content

Commit

Permalink
[#58] Ignore the fact that should_receive expectations will fail to b…
Browse files Browse the repository at this point in the history
…e satisfied in tests that raise errors earlier
  • Loading branch information
alindeman committed Jun 17, 2011
1 parent fdbce6c commit 36d9781
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions spec/rspec/mocks/any_instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,14 @@ class RSpec::SampleRspecTestClass;end
end

it "fails when the arguments match but different instances are used" do
instances = Array.new(2) { klass.new }
expect do
klass.new.foo(:param_one, :param_two).should eq(:result_one)
klass.new.foo(:param_three, :param_four).should eq(:result_two)
instances[0].foo(:param_one, :param_two).should eq(:result_one)
instances[1].foo(:param_three, :param_four).should eq(:result_two)
end.to raise_error(RSpec::Mocks::MockExpectationError)

# ignore the fact that should_receive expectations were not met
instances.each { |instance| instance.rspec_reset }
end

it "is not affected by the invocation of existing methods on other instances" do
Expand All @@ -357,9 +361,13 @@ class RSpec::SampleRspecTestClass;end
end

it "fails when arguments do not match" do
instance = klass.new
expect do
klass.new.foo(:param_one, :param_three)
instance.foo(:param_one, :param_three)
end.to raise_error(RSpec::Mocks::MockExpectationError)

# ignore the fact that should_receive expectations were not met
instance.rspec_reset
end
end

Expand Down Expand Up @@ -658,4 +666,4 @@ class RSpec::SampleRspecTestClass;end

end
end
end
end

0 comments on commit 36d9781

Please sign in to comment.