Skip to content

Commit

Permalink
dont use a fluent style interface to inject order group
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Oct 23, 2013
1 parent 61d4399 commit 1078707
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 24 deletions.
13 changes: 2 additions & 11 deletions lib/rspec/mocks/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,19 @@ module RSpec
module Mocks
# @private
class Proxy
class NullOrderGroup
def invoked(object, message)
end
end

# @private
def initialize(object, name=nil, options={})
def initialize(object, order_group, name=nil, options={})
@object = object
@order_group = order_group
@name = name
@error_generator = ErrorGenerator.new(object, name)
@expectation_ordering = RSpec::Mocks::space.expectation_ordering
@messages_received = []
@options = options
@order_group = NullOrderGroup.new
@null_object = false
end

def with_order_group(group)
@order_group = group
self
end

# @private
attr_reader :object

Expand Down
4 changes: 2 additions & 2 deletions lib/rspec/mocks/proxy_for_nil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module Mocks
# @private
class ProxyForNil < Proxy

def initialize
def initialize(order_group)
@warn_about_expectations = true
super nil
super nil, order_group
end
attr_accessor :warn_about_expectations
alias warn_about_expectations? warn_about_expectations
Expand Down
6 changes: 3 additions & 3 deletions lib/rspec/mocks/space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def proxy_for(object)
id = id_for(object)
proxies.fetch(id) do
proxies[id] = case object
when NilClass then ProxyForNil.new
when TestDouble then object.__build_mock_proxy.with_order_group(expectation_ordering)
when NilClass then ProxyForNil.new(expectation_ordering)
when TestDouble then object.__build_mock_proxy(expectation_ordering)
else
PartialMockProxy.new(object).with_order_group(expectation_ordering)
PartialMockProxy.new(object,expectation_ordering)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rspec/mocks/test_double.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def respond_to?(message, incl_private=false)
end

# @private
def __build_mock_proxy
Proxy.new(self, @name)
def __build_mock_proxy(order_group)
Proxy.new(self, order_group, @name)
end

private
Expand Down
8 changes: 4 additions & 4 deletions lib/rspec/mocks/verifying_double.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def initialize(doubled_module, *args)
__initialize_as_test_double(doubled_module, *args)
end

def __build_mock_proxy
VerifyingProxy.new(self,
def __build_mock_proxy(order_group)
VerifyingProxy.new(self, order_group,
@doubled_module,
InstanceMethodReference
)
Expand All @@ -47,8 +47,8 @@ def initialize(doubled_module, *args)
__initialize_as_test_double(doubled_module, *args)
end

def __build_mock_proxy
VerifyingProxy.new(self,
def __build_mock_proxy(order_group)
VerifyingProxy.new(self, order_group,
@doubled_module,
ObjectMethodReference
)
Expand Down
4 changes: 2 additions & 2 deletions lib/rspec/mocks/verifying_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module Mocks
#
# @api private
class VerifyingProxy < Proxy
def initialize(object, name, method_reference_class)
super(object)
def initialize(object, order_group, name, method_reference_class)
super(object, order_group)
@object = object
@doubled_module = name
@method_reference_class = method_reference_class
Expand Down

0 comments on commit 1078707

Please sign in to comment.