Class: Mocktail::FindsSatisfaction

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/mocktail/handles_dry_call/fulfills_stubbing/finds_satisfaction.rb,
lib/mocktail/sorbet/mocktail/handles_dry_call/fulfills_stubbing/finds_satisfaction.rb

Instance Method Summary collapse

Constructor Details

#initializeFindsSatisfaction

Returns a new instance of FindsSatisfaction.



7
8
9
# File 'lib/mocktail/handles_dry_call/fulfills_stubbing/finds_satisfaction.rb', line 7

def initialize
  @determines_matching_calls = DeterminesMatchingCalls.new
end

Instance Method Details

#find(dry_call) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/mocktail/handles_dry_call/fulfills_stubbing/finds_satisfaction.rb', line 11

def find(dry_call)
  Mocktail.cabinet.stubbings.reverse.find { |stubbing|
    demo_config_times = stubbing.demo_config.times

    @determines_matching_calls.determine(dry_call, stubbing.recording, stubbing.demo_config) &&
      (demo_config_times.nil? || demo_config_times > stubbing.satisfaction_count)
  }
end