Class: Pact::MockService::Interactions::InteractionMismatch::CandidateDiff
- Inherits:
-
Object
- Object
- Pact::MockService::Interactions::InteractionMismatch::CandidateDiff
- Defined in:
- lib/pact/mock_service/interactions/interaction_mismatch.rb
Instance Attribute Summary collapse
-
#actual_request ⇒ Object
Returns the value of attribute actual_request.
-
#candidate_interaction ⇒ Object
Returns the value of attribute candidate_interaction.
Instance Method Summary collapse
- #diff ⇒ Object
- #diff_formatter ⇒ Object
-
#initialize(candidate_interaction, actual_request) ⇒ CandidateDiff
constructor
A new instance of CandidateDiff.
- #mismatched_attributes ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(candidate_interaction, actual_request) ⇒ CandidateDiff
Returns a new instance of CandidateDiff.
41 42 43 44 |
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 41 def initialize candidate_interaction, actual_request @candidate_interaction = candidate_interaction @actual_request = actual_request end |
Instance Attribute Details
#actual_request ⇒ Object
Returns the value of attribute actual_request.
39 40 41 |
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 39 def actual_request @actual_request end |
#candidate_interaction ⇒ Object
Returns the value of attribute candidate_interaction.
39 40 41 |
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 39 def candidate_interaction @candidate_interaction end |
Instance Method Details
#diff ⇒ Object
67 68 69 |
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 67 def diff @diff ||= candidate_interaction.request.difference(actual_request) end |
#diff_formatter ⇒ Object
63 64 65 |
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 63 def diff_formatter Pact.configuration.diff_formatter_for_content_type(candidate_interaction.request.content_type) end |
#mismatched_attributes ⇒ Object
46 47 48 |
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 46 def mismatched_attributes diff.keys end |
#to_hash ⇒ Object
50 51 52 53 54 |
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 50 def to_hash summary = {:description => candidate_interaction.description} summary[:provider_state] = candidate_interaction.provider_state if candidate_interaction.provider_state summary.merge(diff) end |
#to_s ⇒ Object
56 57 58 59 60 61 |
# File 'lib/pact/mock_service/interactions/interaction_mismatch.rb', line 56 def to_s [ "Diff with interaction: #{candidate_interaction.description_with_provider_state_quoted}", diff_formatter.call(diff, **{colour: false}) ].join("\n") end |