Class Spec::Mocks::Mock
In: lib/spec/mocks/mock.rb
Parent: Object

Methods

Included Modules

MockMethods

Public Class methods

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.

[Source]

    # File lib/spec/mocks/mock.rb, line 9
 9:       def initialize(name, options={})
10:         @name = name
11:         @options = options
12:       end

Public Instance methods

[Source]

    # File lib/spec/mocks/mock.rb, line 14
14:       def method_missing(sym, *args, &block)
15:         __mock_handler.instance_eval {@messages_received << [sym, args, block]}
16:         begin
17:           return self if __mock_handler.null_object?
18:           super(sym, *args, &block)
19:         rescue NoMethodError
20:           __mock_handler.raise_unexpected_message_error sym, *args
21:         end
22:       end

[Validate]