Included modules
Public class methods
new
(name, stubs_and_options={})
Creates a new mock with a name (that will be used in error messages only) == Options:
- :null_object - if true, the mock object acts as a forgiving null object allowing any message to be sent to it.
[show source]
# File lib/spec/mocks/mock.rb, line 10 def initialize(name, stubs_and_options={}) @name = name @options = parse_options(stubs_and_options) assign_stubs(stubs_and_options) end
Public instance methods
==
(other)
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.
[show source]
# File lib/spec/mocks/mock.rb, line 20 def ==(other) other == __mock_proxy end
inspect
()
[show source]
# File lib/spec/mocks/mock.rb, line 34 def inspect "#<#{self.class}:#{sprintf '0x%x', self.object_id} @name=#{@name.inspect}>" end
method_missing
(sym, *args, &block)
[show source]
# File lib/spec/mocks/mock.rb, line 24 def method_missing(sym, *args, &block) __mock_proxy.record_message_received(sym, args, block) begin return self if __mock_proxy.null_object? super(sym, *args, &block) rescue NameError __mock_proxy.raise_unexpected_message_error sym, *args end end
to_s
()
[show source]
# File lib/spec/mocks/mock.rb, line 38 def to_s inspect.gsub('<','[').gsub('>',']') end