Sha256: efe0426013d3f1581b06d4de08452d2ee527d3556feb7fcea745fcf3dd6c072a
Contents?: true
Size: 1.03 KB
Versions: 4
Compression:
Stored size: 1.03 KB
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, *args) return !received?(symbol, *args) end def received?(symbol, *args) method = received(symbol) return false if method.nil? argument_set = method.called_with(*args) return !argument_set.nil? end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
fakes-1.1.6 | lib/fakes/fake.rb |
fakes-1.1.5 | lib/fakes/fake.rb |
fakes-1.1.4 | lib/fakes/fake.rb |
fakes-1.1.3 | lib/fakes/fake.rb |