Class: Pact::MockService::Session
- Inherits:
-
Object
- Object
- Pact::MockService::Session
- Defined in:
- lib/pact/mock_service/session.rb
Instance Attribute Summary collapse
-
#actual_interactions ⇒ Object
readonly
Returns the value of attribute actual_interactions.
-
#consumer_contract_details ⇒ Object
readonly
Returns the value of attribute consumer_contract_details.
-
#expected_interactions ⇒ Object
readonly
Returns the value of attribute expected_interactions.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#verified_interactions ⇒ Object
readonly
Returns the value of attribute verified_interactions.
Instance Method Summary collapse
- #add_expected_interaction(interaction) ⇒ Object
- #clear_all ⇒ Object
- #clear_expected_and_actual_interactions ⇒ Object
-
#initialize(options) ⇒ Session
constructor
A new instance of Session.
- #pact_written? ⇒ Boolean
- #record_pact_written ⇒ Object
- #set_expected_interactions(interactions) ⇒ Object
Constructor Details
#initialize(options) ⇒ Session
Returns a new instance of Session.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pact/mock_service/session.rb', line 14 def initialize @pact_written = false @logger = [:logger] @expected_interactions = Interactions::ExpectedInteractions.new @actual_interactions = Interactions::ActualInteractions.new @verified_interactions = Interactions::VerifiedInteractions.new @warn_on_too_many_interactions = [:warn_on_too_many_interactions] || false @max_concurrent_interactions_before_warning = get_max_concurrent_interactions_before_warning @consumer_contract_details = { pact_dir: [:pact_dir], consumer: {name: [:consumer]}, provider: {name: [:provider]}, interactions: verified_interactions, pact_specification_version: [:pact_specification_version], pactfile_write_mode: [:pactfile_write_mode] } end |
Instance Attribute Details
#actual_interactions ⇒ Object (readonly)
Returns the value of attribute actual_interactions.
12 13 14 |
# File 'lib/pact/mock_service/session.rb', line 12 def actual_interactions @actual_interactions end |
#consumer_contract_details ⇒ Object (readonly)
Returns the value of attribute consumer_contract_details.
12 13 14 |
# File 'lib/pact/mock_service/session.rb', line 12 def consumer_contract_details @consumer_contract_details end |
#expected_interactions ⇒ Object (readonly)
Returns the value of attribute expected_interactions.
12 13 14 |
# File 'lib/pact/mock_service/session.rb', line 12 def expected_interactions @expected_interactions end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
12 13 14 |
# File 'lib/pact/mock_service/session.rb', line 12 def logger @logger end |
#verified_interactions ⇒ Object (readonly)
Returns the value of attribute verified_interactions.
12 13 14 |
# File 'lib/pact/mock_service/session.rb', line 12 def verified_interactions @verified_interactions end |
Instance Method Details
#add_expected_interaction(interaction) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/pact/mock_service/session.rb', line 59 def add_expected_interaction interaction if (previous_interaction = interaction_already_verified_with_same_description_and_provider_state_but_not_equal(interaction)) handle_almost_duplicate_interaction previous_interaction, interaction else really_add_expected_interaction interaction end end |
#clear_all ⇒ Object
52 53 54 55 56 57 |
# File 'lib/pact/mock_service/session.rb', line 52 def clear_all expected_interactions.clear actual_interactions.clear verified_interactions.clear @pact_written = false end |
#clear_expected_and_actual_interactions ⇒ Object
47 48 49 50 |
# File 'lib/pact/mock_service/session.rb', line 47 def clear_expected_and_actual_interactions expected_interactions.clear actual_interactions.clear end |
#pact_written? ⇒ Boolean
32 33 34 |
# File 'lib/pact/mock_service/session.rb', line 32 def pact_written? @pact_written end |
#record_pact_written ⇒ Object
36 37 38 |
# File 'lib/pact/mock_service/session.rb', line 36 def record_pact_written @pact_written = true end |
#set_expected_interactions(interactions) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/pact/mock_service/session.rb', line 40 def set_expected_interactions interactions clear_expected_and_actual_interactions interactions.each do | interaction | add_expected_interaction interaction end end |