Sha256: 53a6ea53a98e779b69a3659520238ef5762dd403e37c0287855206da65c0bc30

Contents?: true

Size: 864 Bytes

Versions: 3

Compression:

Stored size: 864 Bytes

Contents

module DevelopWithPassion
  module Fakes
    class Fake
      def initialize(invocation_set = {})
        @method_invocations = invocation_set
      end

      def method_missing(name,*args,&block)
        return @method_invocations.has_key?(name.to_sym) ? @method_invocations[name.to_sym].invoke(*args) : handle_unexpected_method_invocation(name,*args,block)
      end

      def handle_unexpected_method_invocation(name,*args,block)
        method = stub(name.to_sym)
        method.ignore_arg
        return method.invoke(*args)
      end

      def stub(symbol)
        return @method_invocations[symbol] || @method_invocations[symbol] = MethodStub.new
      end

      def received(symbol)
        return @method_invocations[symbol]
      end

      def never_received?(symbol)
        return !@method_invocations.has_key?(symbol)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
developwithpassion_fakes-0.0.3 lib/developwithpassion_fakes/fake.rb
developwithpassion_fakes-0.0.2 lib/developwithpassion_fakes/fake.rb
developwithpassion_fakes-0.0.1 lib/developwithpassion_fakes/fake.rb