Module: Expectations::MockRecorder

Defined in:
lib/expectations/mock_recorder.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



12
13
14
15
16
# File 'lib/expectations/mock_recorder.rb', line 12

def method_missing(sym, *args)
  super if method_stack.empty?
  method_stack << [sym, args]
  self
end

Instance Method Details

#method_stackObject



8
9
10
# File 'lib/expectations/mock_recorder.rb', line 8

def method_stack
  @method_stack ||= []
end

#mocha_error_message(ex) ⇒ Object



27
28
29
# File 'lib/expectations/mock_recorder.rb', line 27

def mocha_error_message(ex)
  ex.message
end

#receive!(method) ⇒ Object



3
4
5
6
# File 'lib/expectations/mock_recorder.rb', line 3

def receive!(method)
  method_stack << [:expects, [method]]
  self
end

#subject!Object



18
19
20
21
# File 'lib/expectations/mock_recorder.rb', line 18

def subject!
  method_stack.inject(subject) { |result, element| result.send element.first, *element.last }
  subject
end

#verifyObject



23
24
25
# File 'lib/expectations/mock_recorder.rb', line 23

def verify
  true
end