class Mocha::Invocation
Attributes
block[R]
method_name[R]
Public Class Methods
new(mock, method_name, arguments = [], block = nil)
click to toggle source
# File lib/mocha/invocation.rb, line 11 def initialize(mock, method_name, arguments = [], block = nil) @mock = mock @method_name = method_name @arguments = arguments @block = block @yields = [] @result = nil end
Public Instance Methods
arguments()
click to toggle source
# File lib/mocha/invocation.rb, line 41 def arguments @arguments.dup end
call(yield_parameters = YieldParameters.new, return_values = ReturnValues.new)
click to toggle source
# File lib/mocha/invocation.rb, line 20 def call(yield_parameters = YieldParameters.new, return_values = ReturnValues.new) yield_parameters.next_invocation.each do |yield_args| @yields << ParametersMatcher.new(yield_args) raise LocalJumpError unless @block @block.call(*yield_args) end return_values.next(self) end
call_description()
click to toggle source
# File lib/mocha/invocation.rb, line 45 def call_description description = "#{@mock.mocha_inspect}.#{@method_name}#{argument_description}" description << ' { ... }' unless @block.nil? description end
full_description()
click to toggle source
# File lib/mocha/invocation.rb, line 61 def full_description "\n - #{call_description} #{result_description}" end
raised(exception)
click to toggle source
# File lib/mocha/invocation.rb, line 33 def raised(exception) @result = RaisedException.new(exception) end
result_description()
click to toggle source
# File lib/mocha/invocation.rb, line 55 def result_description desc = "# => #{@result.mocha_inspect}" desc << " after yielding #{@yields.map(&:mocha_inspect).join(', then ')}" if @yields.any? desc end
returned(value)
click to toggle source
# File lib/mocha/invocation.rb, line 29 def returned(value) @result = value end
short_call_description()
click to toggle source
# File lib/mocha/invocation.rb, line 51 def short_call_description "#{@method_name}(#{@arguments.join(', ')})" end
threw(tag, value)
click to toggle source
# File lib/mocha/invocation.rb, line 37 def threw(tag, value) @result = ThrownObject.new(tag, value) end
Private Instance Methods
argument_description()
click to toggle source
# File lib/mocha/invocation.rb, line 67 def argument_description signature = arguments.mocha_inspect signature = signature.gsub(/^\[|\]$/, '') "(#{signature})" end