Sha256: 56b59f7d05befd039d03f6f9f6e070ec139dae22edb94c87334bbeafba6c1492

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 KB

Contents

require 'mocha/mock'
require 'bourne/expectation'

module Mocha # :nodoc:
  # Overwrites #method_missing on Mocha::Mock so pass arguments to
  # Mocha::Expectation#invoke so that an Invocation can be created.
  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 ExpectationError.new(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

8 entries across 8 versions & 3 rubygems

Version Path
challah-1.0.0.beta vendor/bundle/gems/bourne-1.1.2/lib/bourne/mock.rb
challah-0.9.1.beta.3 vendor/bundle/gems/bourne-1.1.2/lib/bourne/mock.rb
devise_sociable-0.1.0 vendor/bundle/gems/bourne-1.1.2/lib/bourne/mock.rb
challah-0.9.1.beta vendor/bundle/gems/bourne-1.1.2/lib/bourne/mock.rb
challah-0.9.0 vendor/bundle/gems/bourne-1.1.2/lib/bourne/mock.rb
bourne-1.1.2 lib/bourne/mock.rb
bourne-1.1.1 lib/bourne/mock.rb
bourne-1.1.0 lib/bourne/mock.rb