Class: Pact::Consumer::InteractionBuilder
- Inherits:
-
Object
- Object
- Pact::Consumer::InteractionBuilder
- Defined in:
- lib/pact/consumer/interaction_builder.rb
Instance Attribute Summary collapse
-
#interaction ⇒ Object
readonly
Returns the value of attribute interaction.
Instance Method Summary collapse
- #given(provider_state) ⇒ Object
-
#initialize(&block) ⇒ InteractionBuilder
constructor
A new instance of InteractionBuilder.
- #upon_receiving(description) ⇒ Object
- #will_respond_with(response) ⇒ Object
- #with(request_details) ⇒ Object
- #without_writing_to_pact ⇒ Object
Constructor Details
#initialize(&block) ⇒ InteractionBuilder
Returns a new instance of InteractionBuilder.
11 12 13 14 |
# File 'lib/pact/consumer/interaction_builder.rb', line 11 def initialize &block @interaction = Interaction.new @callback = block end |
Instance Attribute Details
#interaction ⇒ Object (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
27 28 29 30 |
# File 'lib/pact/consumer/interaction_builder.rb', line 27 def given provider_state @interaction.provider_state = provider_state.nil? ? nil : provider_state.to_s self end |
#upon_receiving(description) ⇒ Object
22 23 24 25 |
# File 'lib/pact/consumer/interaction_builder.rb', line 22 def upon_receiving description @interaction.description = description self end |
#will_respond_with(response) ⇒ Object
37 38 39 40 41 |
# File 'lib/pact/consumer/interaction_builder.rb', line 37 def will_respond_with(response) interaction.response = Pact::Response.new(response) @callback.call interaction self end |
#with(request_details) ⇒ Object
32 33 34 35 |
# File 'lib/pact/consumer/interaction_builder.rb', line 32 def with(request_details) interaction.request = Pact::Request::Expected.from_hash(request_details) self end |
#without_writing_to_pact ⇒ Object
16 17 18 19 20 |
# File 'lib/pact/consumer/interaction_builder.rb', line 16 def without_writing_to_pact interaction. ||= {} interaction.[:write_to_pact] = false self end |