- Defined in:
A verifying proxy mostly acts like a normal proxy, except that it contains extra logic to try and determine the validity of any expectation set on it. This includes whether or not methods have been defined and the validatiy of arguments on method calls.
In all other ways this behaves like a normal proxy. It only adds the verification behaviour to specific methods then delegates to the parent implementation.
These checks are only activated if the doubled class has already been loaded, otherwise they are disabled. This allows for testing in isolation.
Instance Attribute Summary
Attributes inherited from
Instance Method Summary (collapse)
- (VerifyingProxy) initialize(object, order_group, name, method_reference_class)
A new instance of VerifyingProxy.
- - (Object) method_reference
- - (Object) visibility_for(method_name)
Methods included from
, , , ,
Methods inherited from
, , , , , , , , , , , , , , , , , , , , ,
- () initialize(object, order_group, name, method_reference_class)
Returns a new instance of VerifyingProxy
60 61 62 63 64 65 66 67 68 69 70 71 72
# File 'lib/rspec/mocks/verifying_proxy.rb', line 60 def initialize(object, order_group, name, method_reference_class) super(object, order_group) @object = object @doubled_module = name @method_reference_class = method_reference_class # A custom method double is required to pass through a way to lookup # methods to determine their parameters. This is only relevant if the doubled # class is loaded. @method_doubles = Hash.new do |h, k| h[k] = VerifyingMethodDouble.new(@object, k, self, method_reference[k]) end end
Instance Method Details
- (Object) method_reference
74 75 76 77 78
# File 'lib/rspec/mocks/verifying_proxy.rb', line 74 def method_reference @method_reference ||= Hash.new do |h, k| h[k] = @method_reference_class.new(@doubled_module, k) end end
- (Object) visibility_for(method_name)
80 81 82
# File 'lib/rspec/mocks/verifying_proxy.rb', line 80 def visibility_for(method_name) method_reference[method_name].visibility end