Class: Mocha::TerseMock

Inherits:
Object show all
Defined in:
lib/mocha/shot/terse_mock.rb

Instance Method Summary collapse

Constructor Details

#initialize(mock, backtrace) ⇒ TerseMock

Returns a new instance of TerseMock.



3
4
5
6
# File 'lib/mocha/shot/terse_mock.rb', line 3

def initialize(mock, backtrace)
  @mock = mock
  @backtrace = backtrace
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/mocha/shot/terse_mock.rb', line 8

def method_missing(method_name, *args, &block)
  if block
    @mock.__expects__(method_name, @backtrace).with(*args).returns(block)
  else
    @mock.__expects__(method_name, @backtrace).with(*args)
  end
end