Object
Creates a new test double with a `name` (that will be used in error messages only)
# File lib/rspec/mocks/mock.rb, line 8 def initialize(name=nil, stubs_and_options={}) if name.is_a?(Hash) && stubs_and_options.empty? stubs_and_options = name @name = nil else @name = name end @options = extract_options(stubs_and_options) assign_stubs(stubs_and_options) end
This allows for comparing the mock to other objects that proxy such as ActiveRecords belongs_to proxy objects. By making the other object run the comparison, we're sure the call gets delegated to the proxy target.
# File lib/rspec/mocks/mock.rb, line 23 def ==(other) other == __mock_proxy end
@private
# File lib/rspec/mocks/mock.rb, line 28 def inspect "#<#{self.class}:#{sprintf '0x%x', self.object_id} @name=#{@name.inspect}>" end
@private
# File lib/rspec/mocks/mock.rb, line 40 def respond_to?(sym, incl_private=false) __mock_proxy.null_object? && sym != :to_ary ? true : super end
@private
# File lib/rspec/mocks/mock.rb, line 33 def to_s inspect.gsub('<','[').gsub('>',']') end
Generated with the Darkfish Rdoc Generator 2.