Sha256: c1e5c76ed8fefbedc306767dbc41015195287dbf0e43121f180a580c173db461

Contents?: true

Size: 712 Bytes

Versions: 1

Compression:

Stored size: 712 Bytes

Contents

# typed: strict

require_relative "../../share/determines_matching_calls"

module Mocktail
  class FindsSatisfaction
    extend T::Sig

    sig { void }
    def initialize
      @determines_matching_calls = T.let(DeterminesMatchingCalls.new, Mocktail::DeterminesMatchingCalls)
    end

    sig { params(dry_call: Call).returns(T.nilable(Stubbing[T.anything])) }
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mocktail-2.0.0 lib/mocktail/sorbet/mocktail/handles_dry_call/fulfills_stubbing/finds_satisfaction.rb