Class: Pact::Message::Consumer::ConsumerContractBuilder
- Inherits:
-
Object
- Object
- Pact::Message::Consumer::ConsumerContractBuilder
- Defined in:
- lib/pact/message/consumer/consumer_contract_builder.rb
Instance Method Summary collapse
- #given(provider_state, params = {}) ⇒ Object
- #handle_interaction_fully_defined(interaction) ⇒ Object
-
#initialize(attributes) ⇒ ConsumerContractBuilder
constructor
A new instance of ConsumerContractBuilder.
- #is_expected_to_send(description) ⇒ Object
- #reset ⇒ Object
- #send_message_hash ⇒ Object
- #send_message_string ⇒ Object
- #verify(example_description) ⇒ Object
- #write_pact ⇒ Object
Constructor Details
#initialize(attributes) ⇒ ConsumerContractBuilder
Returns a new instance of ConsumerContractBuilder.
10 11 12 13 14 15 16 17 18 |
# File 'lib/pact/message/consumer/consumer_contract_builder.rb', line 10 def initialize(attributes) @interaction_builder = nil @consumer_name = attributes[:consumer_name] @provider_name = attributes[:provider_name] @pact_specification_version = attributes[:pact_specification_version] @pact_dir = attributes[:pact_dir] @interactions = [] @yielded_interaction = false end |
Instance Method Details
#given(provider_state, params = {}) ⇒ Object
25 26 27 |
# File 'lib/pact/message/consumer/consumer_contract_builder.rb', line 25 def given(provider_state, params = {}) interaction_builder.given(provider_state, params) end |
#handle_interaction_fully_defined(interaction) ⇒ Object
55 56 57 58 |
# File 'lib/pact/message/consumer/consumer_contract_builder.rb', line 55 def handle_interaction_fully_defined(interaction) @contents = interaction.contents @contents_string = interaction.contents.to_s end |
#is_expected_to_send(description) ⇒ Object
29 30 31 |
# File 'lib/pact/message/consumer/consumer_contract_builder.rb', line 29 def is_expected_to_send(description) interaction_builder.is_expected_to_send(provider_state) end |
#reset ⇒ Object
20 21 22 23 |
# File 'lib/pact/message/consumer/consumer_contract_builder.rb', line 20 def reset @interaction_builder = nil @yielded_interaction = false end |
#send_message_hash ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pact/message/consumer/consumer_contract_builder.rb', line 44 def if interaction_builder? if block_given? @yielded_interaction = true yield interaction_builder.interaction.contents.reified_contents_hash end else raise Pact::Error.new("No message expectation has been defined") end end |
#send_message_string ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pact/message/consumer/consumer_contract_builder.rb', line 33 def if interaction_builder? if block_given? @yielded_interaction = true yield interaction_builder.interaction.contents.reified_contents_string end else raise Pact::Error.new("No message expectation has been defined") end end |
#verify(example_description) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pact/message/consumer/consumer_contract_builder.rb', line 60 def verify example_description # There may be multiple message providers defined, and not every one of them # has to define a message for every test. if interaction_builder? if yielded_interaction? interactions << interaction_builder.interaction else raise Pact::Error.new("`send_message_string` was not called for message \"#{interaction_builder.interaction.description}\"") end end end |