Sha256: 824a8f95547b39152ff15452ee3a7131ffc511a23c95928b0e8ce7f8577b9485
Contents?: true
Size: 822 Bytes
Versions: 1
Compression:
Stored size: 822 Bytes
Contents
module Fakes class MethodStub def initialize(arg_sets = []) @arg_sets = arg_sets end def with(*args) return add_new_set(ArgSet.new(args)) end def add_new_set(set) @arg_sets << set set end def ignore_arg return add_new_set(IgnoreSet.new) end def and_return(item) ignore_arg.and_return(item) end def invoke(args) set = @arg_sets.find{|item| item.matches?(args)} || ignore_arg set.capture_args(args) return set.return_value end def called_with(*args) return @arg_sets.find{|item| item.was_called_with?(args)} end def total_times_called return @arg_sets.inject(0){|sum,item|sum += item.times_called} end def times?(value) return total_times_called == value end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fakes-0.1.7 | lib/fakes/method_stub.rb |