A recording that represents a method call it contains argument variations that can be matched too
Initializes a new instance of a method call recording every time a method gets called in an isolated object this gets stored in the method call recorder It expects a method_name at the very least.
# File lib/caricature/method_call_recorder.rb, line 98
98: def initialize(method_name, count=0)
99: @method_name = method_name
100: @count = count
101: @variations = []
102: end
add an argument variation
# File lib/caricature/method_call_recorder.rb, line 115
115: def add_argument_variation(args, block)
116: variation = find_argument_variations args, nil
117: if variation.empty?
118: @variations << ArgumentRecording.new(args, @variations.size+1, block) if variation == []
119: else
120: variation.first.call_number += 1
121: end
122: end
add args
# File lib/caricature/method_call_recorder.rb, line 105
105: def args
106: @variations
107: end
finds an argument variation that matches the provided args
# File lib/caricature/method_call_recorder.rb, line 125
125: def find_argument_variations(args, block_args)
126: return @variations if args.first.is_a?(Symbol) and args.last == :any
127: return match_hash(args, block_args) if args.size == 1 and args.last.is_a?(Hash)
128: return @variations.select { |ar| ar.args == args } if block_args.nil?
129: return @variations.select { |ar| ar.args == args and ar.block } if block_args.last == :any
130: return @variations.select do |ar|
131: av = ar.args == args
132: # idx = 0
133: # ags = ar.args
134: # av = args.all? do |ag|
135: # rag = ags[idx]
136: # res = if ag.is_a?(Hash) and rag.is_a?(Hash)
137: # ag.all? { |k, v| ar.args[idx][k] == v }
138: # else
139: # ag == rag
140: # end
141: # idx += 1
142: # res
143: # end
144: av and not ar.find_block_variation(*block_args).empty?
145: end
146: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.