Sha256: a582e76ae2f897a3d45ba40ff587b425529552e1a8dded37594e557f802a12bb

Contents?: true

Size: 870 Bytes

Versions: 15

Compression:

Stored size: 870 Bytes

Contents

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 send(name,*args,&block)
      return method_missing(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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fakes-1.1.2 lib/fakes/fake.rb
fakes-1.0.31 lib/core/fake.rb
fakes-1.0.30 lib/core/fake.rb
fakes-1.0.25 lib/core/fake.rb
fakes-1.1.1 lib/fakes/fake.rb
fakes-1.0.24 lib/core/fake.rb
fakes-1.0.22 lib/core/fake.rb
fakes-1.1.0 lib/fakes/fake.rb
fakes-1.0.9 lib/fakes/fake.rb
fakes-1.0.8 lib/fakes/fake.rb
fakes-1.0.7 lib/fakes/fake.rb
fakes-1.0.6 lib/fakes/fake.rb
fakes-1.0.5 lib/core/fake.rb
fakes-1.0.2 lib/core/fake.rb
fakes-1.0.1 lib/core/fake.rb