Permalink
Browse files

Only reset any_instance recorder once.

  • Loading branch information...
1 parent ef65d36 commit 189fda06c40f8b2975079c67584398303031e96f @dchelimsky dchelimsky committed Apr 17, 2011
Showing with 4 additions and 10 deletions.
  1. +0 −5 lib/rspec/mocks/any_instance.rb
  2. +4 −5 spec/rspec/mocks/any_instance_spec.rb
@@ -234,13 +234,8 @@ def rspec_verify
__recorder.verify
super
ensure
- rspec_reset
- end
-
- def rspec_reset
__recorder.stop_observing!
@__recorder = nil
- super
end
def __recorder
@@ -482,7 +482,7 @@ class RSpec::SampleRspecTestClass;end
end
end
- context "when resetting after an example" do
+ context "when resetting post-verification" do
let(:space) { RSpec::Mocks::Space.new }
context "existing method" do
@@ -497,7 +497,7 @@ class RSpec::SampleRspecTestClass;end
end
it "restores the class to its original state after each example when no instance is created" do
- space.reset_all
+ space.verify_all
klass.method_defined?(:__existing_method_without_any_instance__).should be_false
klass.new.existing_method.should eq(existing_method_return_value)
@@ -506,7 +506,7 @@ class RSpec::SampleRspecTestClass;end
it "restores the class to its original state after each example when one instance is created" do
klass.new.existing_method
- space.reset_all
+ space.verify_all
klass.method_defined?(:__existing_method_without_any_instance__).should be_false
klass.new.existing_method.should eq(existing_method_return_value)
@@ -516,7 +516,7 @@ class RSpec::SampleRspecTestClass;end
klass.new.existing_method
klass.new.existing_method
- space.reset_all
+ space.verify_all
klass.method_defined?(:__existing_method_without_any_instance__).should be_false
klass.new.existing_method.should eq(existing_method_return_value)
@@ -556,7 +556,6 @@ class RSpec::SampleRspecTestClass;end
klass.any_instance.should_receive(:existing_method).and_return(Object.new)
klass.new.existing_method
space.verify_all
- space.reset_all
klass.new.existing_method.should eq(existing_method_return_value)
end

0 comments on commit 189fda0

Please sign in to comment.