Permalink
Browse files

Play with seperating all proxies from current proxies.

  • Loading branch information...
1 parent 37fbb27 commit b2204955f7c474fca4aaeb44f3438ec262f54a13 @myronmarston myronmarston committed Mar 30, 2013
Showing with 10 additions and 6 deletions.
  1. +10 −6 lib/rspec/mocks/space.rb
View
@@ -6,11 +6,12 @@ class Space
def initialize
@proxies = {}
+ @current_example_proxies = Set.new
end
def verify_all
- proxies.each_value do |object|
- object.verify
+ @current_example_proxies.each do |proxy|
+ proxy.verify
end
AnyInstance.verify_all
@@ -20,11 +21,11 @@ def reset_all
ConstantMutator.reset_all
AnyInstance.reset_all
- proxies.each_value do |object|
- object.reset
+ @current_example_proxies.each do |proxy|
+ proxy.reset
end
- proxies.clear
+ @current_example_proxies.clear
expectation_ordering.clear
end
@@ -33,13 +34,16 @@ def expectation_ordering
end
def proxy_for(object)
- proxies.fetch(object.object_id) do
+ proxy = proxies.fetch(object.object_id) do
proxies[object.object_id] = if TestDouble === object
object.__build_mock_proxy
else
Proxy.new(object)
end
end
+
+ @current_example_proxies << proxy
+ proxy
end
alias ensure_registered proxy_for

0 comments on commit b220495

Please sign in to comment.