Module: Expectations::StateBasedRecorder
- Defined in:
- lib/expectations/state_based_recorder.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/expectations/state_based_recorder.rb', line 19
def method_missing(sym, *args)
@message_parts ||= []
@message_parts << "#{sym}"
args.each { |arg| @message_parts << arg.inspect }
method_stack << [sym, args]
self
end
|
Instance Method Details
#failure_message ⇒ Object
7
8
9
|
# File 'lib/expectations/state_based_recorder.rb', line 7
def failure_message
"expected #{subject} #{@message_parts.join(" ")}"
end
|
#message_parts ⇒ Object
15
16
17
|
# File 'lib/expectations/state_based_recorder.rb', line 15
def message_parts
@message_parts ||= self.is_a?(Expectations::ReverseResult) ? [:not] : []
end
|
#method_stack ⇒ Object
11
12
13
|
# File 'lib/expectations/state_based_recorder.rb', line 11
def method_stack
@method_stack ||= []
end
|
3
4
5
|
# File 'lib/expectations/state_based_recorder.rb', line 3
def verify
method_stack.inject(subject) { |result, element| result.send element.first, *element.last }
end
|