Class: Mocktail::FulfillsStubbing

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

Instance Method Summary collapse

Constructor Details

#initializeFulfillsStubbing

Returns a new instance of FulfillsStubbing.



8
9
10
11
# File 'lib/mocktail/handles_dry_call/fulfills_stubbing.rb', line 8

def initialize
  @finds_satisfaction = FindsSatisfaction.new
  @describes_unsatisfied_stubbing = DescribesUnsatisfiedStubbing.new
end

Instance Method Details

#fulfill(dry_call) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/mocktail/handles_dry_call/fulfills_stubbing.rb', line 13

def fulfill(dry_call)
  if (stubbing = satisfaction(dry_call))
    stubbing.satisfied!
    stubbing.effect&.call(dry_call)
  else
    store_unsatisfying_call!(dry_call)
    nil
  end
end

#satisfaction(dry_call) ⇒ Object



23
24
25
26
27
# File 'lib/mocktail/handles_dry_call/fulfills_stubbing.rb', line 23

def satisfaction(dry_call)
  return if Mocktail.cabinet.demonstration_in_progress?

  @finds_satisfaction.find(dry_call)
end