Sha256: 0f32f62cde6185a1152fed56a1f91106da741336944d331b2e2069479f43b078
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
require 'mocha/mock' require 'bourne/expectation' require 'mocha/expectation_error_factory' module Mocha # :nodoc: # Overwrites #method_missing on Mocha::Mock # - pass arguments to .invoke() calls to create Invocation # - keep lowest else branch (bourne code) # - update from https://github.com/freerange/mocha/blob/master/lib/mocha/mock.rb#L195 # - update test/unit/mock_test.rb class Mock # :nodoc: def method_missing(symbol, *arguments, &block) if @responder and not @responder.respond_to?(symbol) raise NoMethodError, "undefined method `#{symbol}' for #{self.mocha_inspect} which responds like #{@responder.mocha_inspect}" end if matching_expectation_allowing_invocation = @expectations.match_allowing_invocation(symbol, *arguments) matching_expectation_allowing_invocation.invoke(arguments, &block) else if (matching_expectation = @expectations.match(symbol, *arguments)) || (!matching_expectation && !@everything_stubbed) matching_expectation.invoke(arguments, &block) if matching_expectation message = UnexpectedInvocation.new(self, symbol, *arguments).to_s message << @mockery.mocha_inspect raise ExpectationErrorFactory.build(message, caller) else target = if self.respond_to? :mocha self.mocha else mocha end Mockery.instance.invocation(target, symbol, arguments) nil end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bourne-1.3.0 | lib/bourne/mock.rb |
bourne-1.2.1 | lib/bourne/mock.rb |
bourne-1.2.0 | lib/bourne/mock.rb |