Class: Pact::Consumer::InteractionList
- Inherits:
-
Object
- Object
- Pact::Consumer::InteractionList
- Defined in:
- lib/pact/consumer/mock_service/interaction_list.rb
Instance Attribute Summary collapse
-
#interactions ⇒ Object
readonly
Returns the value of attribute interactions.
-
#unexpected_requests ⇒ Object
readonly
Returns the value of attribute unexpected_requests.
Instance Method Summary collapse
- #add(interactions) ⇒ Object
- #all_matched? ⇒ Boolean
-
#clear ⇒ Object
For testing, sigh.
- #find_candidate_interactions(actual_request) ⇒ Object
-
#initialize ⇒ InteractionList
constructor
A new instance of InteractionList.
- #interaction_diffs ⇒ Object
- #missing_interactions ⇒ Object
- #register_matched(interaction) ⇒ Object
- #register_unexpected_request(request) ⇒ Object
Constructor Details
#initialize ⇒ InteractionList
Returns a new instance of InteractionList.
8 9 10 |
# File 'lib/pact/consumer/mock_service/interaction_list.rb', line 8 def initialize clear end |
Instance Attribute Details
#interactions ⇒ Object (readonly)
Returns the value of attribute interactions.
5 6 7 |
# File 'lib/pact/consumer/mock_service/interaction_list.rb', line 5 def interactions @interactions end |
#unexpected_requests ⇒ Object (readonly)
Returns the value of attribute unexpected_requests.
6 7 8 |
# File 'lib/pact/consumer/mock_service/interaction_list.rb', line 6 def unexpected_requests @unexpected_requests end |
Instance Method Details
#add(interactions) ⇒ Object
19 20 21 |
# File 'lib/pact/consumer/mock_service/interaction_list.rb', line 19 def add interactions @interactions << interactions end |
#all_matched? ⇒ Boolean
31 32 33 |
# File 'lib/pact/consumer/mock_service/interaction_list.rb', line 31 def all_matched? interaction_diffs.empty? end |
#clear ⇒ Object
For testing, sigh
13 14 15 16 17 |
# File 'lib/pact/consumer/mock_service/interaction_list.rb', line 13 def clear @interactions = [] @matched_interactions = [] @unexpected_requests = [] end |
#find_candidate_interactions(actual_request) ⇒ Object
49 50 51 52 53 |
# File 'lib/pact/consumer/mock_service/interaction_list.rb', line 49 def find_candidate_interactions actual_request interactions.select do | interaction | interaction.request.matches_route? actual_request end end |
#interaction_diffs ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/pact/consumer/mock_service/interaction_list.rb', line 39 def interaction_diffs { :missing_interactions => missing_interactions.collect(&:as_json), :unexpected_requests => unexpected_requests.collect(&:as_json) }.inject({}) do | hash, pair | hash[pair.first] = pair.last if pair.last.any? hash end end |
#missing_interactions ⇒ Object
35 36 37 |
# File 'lib/pact/consumer/mock_service/interaction_list.rb', line 35 def missing_interactions @interactions - @matched_interactions end |
#register_matched(interaction) ⇒ Object
23 24 25 |
# File 'lib/pact/consumer/mock_service/interaction_list.rb', line 23 def register_matched interaction @matched_interactions << interaction end |
#register_unexpected_request(request) ⇒ Object
27 28 29 |
# File 'lib/pact/consumer/mock_service/interaction_list.rb', line 27 def register_unexpected_request request @unexpected_requests << request end |