Skip to content

Commit

Permalink
Play with seperating all proxies from current proxies.
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Mar 30, 2013
1 parent 37fbb27 commit b220495
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/rspec/mocks/space.rb
Expand Up @@ -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
Expand 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

Expand All @@ -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
Expand Down

0 comments on commit b220495

Please sign in to comment.