Class: Lookout::Mock

Inherits:
Stub show all
Defined in:
lib/lookout-3.0/mock.rb

Overview

Object that doesn’t respond to anything except for what’s been explicitly defined on it and throws a mock error whenever it receives a method call.

Instance Method Summary collapse

Methods inherited from Stub

define, #initialize

Constructor Details

This class inherits a constructor from Lookout::Stub

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object (private)

Parameters:

Raises:

  • (Reception::Error)

    When called, including the METHOD that was called and with what ARGS in the messaged and with the proper backtrace, making it easy to see where things went wrong



15
16
17
18
19
20
21
22
23
# File 'lib/lookout-3.0/mock.rb', line 15

def method_missing(method, *args)
  raise Lookout::Reception::Error.
    from('%p#%s(%s)%s' % [self,
                          method,
                          Lookout::Inspect.args(*args),
                          block_given? ? '{ … }' : ''],
         1,
         0..0)
end

Instance Method Details

#inspectObject



6
# File 'lib/lookout-3.0/mock.rb', line 6

def inspect; 'mock' end