Class: Pact::Consumer::InteractionBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/pact/consumer/interaction_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInteractionBuilder

Returns a new instance of InteractionBuilder.



11
12
13
# File 'lib/pact/consumer/interaction_builder.rb', line 11

def initialize
  @interaction = Interaction.new
end

Instance Attribute Details

#interactionObject (readonly)

Returns the value of attribute interaction.



9
10
11
# File 'lib/pact/consumer/interaction_builder.rb', line 9

def interaction
  @interaction
end

Instance Method Details

#given(provider_state) ⇒ Object



20
21
22
23
# File 'lib/pact/consumer/interaction_builder.rb', line 20

def given provider_state
  @interaction.provider_state = provider_state.nil? ? nil : provider_state.to_s
  self
end

#on_interaction_fully_defined(&block) ⇒ Object



36
37
38
# File 'lib/pact/consumer/interaction_builder.rb', line 36

def on_interaction_fully_defined &block
  @callback = block
end

#upon_receiving(description) ⇒ Object



15
16
17
18
# File 'lib/pact/consumer/interaction_builder.rb', line 15

def upon_receiving description
  @interaction.description = description
  self
end

#will_respond_with(response) ⇒ Object



30
31
32
33
34
# File 'lib/pact/consumer/interaction_builder.rb', line 30

def will_respond_with(response)
  interaction.response = response
  @callback.call interaction
  self
end

#with(request_details) ⇒ Object



25
26
27
28
# File 'lib/pact/consumer/interaction_builder.rb', line 25

def with(request_details)
  interaction.request = Pact::Request::Expected.from_hash(request_details)
  self
end