Sha256: 95cfb5179cfea63c9a9d3d790254f22b8ede07ca3f923c543ca5f97bd260c007
Contents?: true
Size: 1.42 KB
Versions: 4
Compression:
Stored size: 1.42 KB
Contents
require 'mocha/parameters_matcher' require 'mocha/raised_exception' require 'mocha/return_values' require 'mocha/thrown_object' require 'mocha/yield_parameters' module Mocha class Invocation attr_reader :method_name def initialize(mock, method_name, *arguments) @mock = mock @method_name = method_name @arguments = arguments @yields = [] @result = nil end def call(yield_parameters = YieldParameters.new, return_values = ReturnValues.new) yield_parameters.next_invocation.each do |yield_args| @yields << ParametersMatcher.new(yield_args) yield(*yield_args) end return_values.next(self) end def returned(value) @result = value end def raised(exception) @result = RaisedException.new(exception) end def threw(tag, value) @result = ThrownObject.new(tag, value) end def arguments @arguments.dup end def call_description "#{@mock.mocha_inspect}.#{@method_name}#{ParametersMatcher.new(@arguments).mocha_inspect}" end def short_call_description "#{@method_name}(#{@arguments.join(', ')})" end def result_description desc = "# => #{@result.mocha_inspect}" desc << " after yielding #{@yields.map(&:mocha_inspect).join(', then ')}" if @yields.any? desc end def full_description "\n - #{call_description} #{result_description}" end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mocha-1.10.1 | lib/mocha/invocation.rb |
mocha-1.10.0 | lib/mocha/invocation.rb |
mocha-1.10.0.beta.1 | lib/mocha/invocation.rb |
mocha-1.10.0.alpha | lib/mocha/invocation.rb |