Class: Gimme::InvokesSatisfiedStubbing
- Inherits:
-
Object
- Object
- Gimme::InvokesSatisfiedStubbing
- Defined in:
- lib/gimme/invokes_satisfied_stubbing.rb
Instance Method Summary collapse
-
#initialize(stubbings) ⇒ InvokesSatisfiedStubbing
constructor
A new instance of InvokesSatisfiedStubbing.
- #invoke(method, args) ⇒ Object
Constructor Details
#initialize(stubbings) ⇒ InvokesSatisfiedStubbing
Returns a new instance of InvokesSatisfiedStubbing.
3 4 5 |
# File 'lib/gimme/invokes_satisfied_stubbing.rb', line 3 def initialize(stubbings) @stubbings = stubbings end |
Instance Method Details
#invoke(method, args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gimme/invokes_satisfied_stubbing.rb', line 7 def invoke(method, args) matching_stub_block = nil @stubbings[method].each do |stub_args,stub_block| matching = args.size == stub_args.size args.each_index do |i| unless args[i] == stub_args[i] || (stub_args[i].respond_to?(:matches?) && stub_args[i].matches?(args[i])) matching = false break end end matching_stub_block = stub_block if matching end if matching_stub_block matching_stub_block.call elsif method.to_s[-1,1] == '?' false else nil end end |