Class: Pact::Message::Consumer::InteractionBuilder
- Inherits:
-
Object
- Object
- Pact::Message::Consumer::InteractionBuilder
- Defined in:
- lib/pact/message/consumer/interaction_builder.rb
Instance Attribute Summary collapse
-
#interaction ⇒ Object
readonly
Returns the value of attribute interaction.
Instance Method Summary collapse
- #given(name, params = {}) ⇒ Object (also: #and)
-
#initialize(&block) ⇒ InteractionBuilder
constructor
A new instance of InteractionBuilder.
- #is_expected_to_send(description) ⇒ Object
- #with_content(object) ⇒ Object
- #with_metadata(object) ⇒ Object
Constructor Details
#initialize(&block) ⇒ InteractionBuilder
Returns a new instance of InteractionBuilder.
10 11 12 13 |
# File 'lib/pact/message/consumer/interaction_builder.rb', line 10 def initialize &block @interaction = Pact::Message.new @callback = block end |
Instance Attribute Details
#interaction ⇒ Object (readonly)
Returns the value of attribute interaction.
8 9 10 |
# File 'lib/pact/message/consumer/interaction_builder.rb', line 8 def interaction @interaction end |
Instance Method Details
#given(name, params = {}) ⇒ Object Also known as: and
20 21 22 23 24 25 |
# File 'lib/pact/message/consumer/interaction_builder.rb', line 20 def given name, params = {} if name @interaction.provider_states << Pact::ProviderState.new(name, params) end self end |
#is_expected_to_send(description) ⇒ Object
15 16 17 18 |
# File 'lib/pact/message/consumer/interaction_builder.rb', line 15 def is_expected_to_send description @interaction.description = description self end |
#with_content(object) ⇒ Object
34 35 36 37 38 |
# File 'lib/pact/message/consumer/interaction_builder.rb', line 34 def with_content(object) interaction.contents = Pact::Message::Contents.from_hash(object) @callback.call interaction self end |
#with_metadata(object) ⇒ Object
29 30 31 32 |
# File 'lib/pact/message/consumer/interaction_builder.rb', line 29 def (object) interaction. = object self end |