Class: Pact::Consumer::MockServiceInteractionExpectation

Inherits:
Object
  • Object
show all
Defined in:
lib/pact/consumer/mock_service_interaction_expectation.rb

Instance Method Summary collapse

Constructor Details

#initialize(interaction) ⇒ MockServiceInteractionExpectation

Returns a new instance of MockServiceInteractionExpectation.



10
11
12
# File 'lib/pact/consumer/mock_service_interaction_expectation.rb', line 10

def initialize interaction
  @interaction = interaction
end

Instance Method Details

#as_json(options = {}) ⇒ Object



23
24
25
# File 'lib/pact/consumer/mock_service_interaction_expectation.rb', line 23

def as_json options = {}
  to_hash
end

#to_hashObject



14
15
16
17
18
19
20
21
# File 'lib/pact/consumer/mock_service_interaction_expectation.rb', line 14

def to_hash
  hash = {:description => interaction.description}
  hash[:provider_state] = interaction.provider_state if interaction.provider_state
  options = interaction.request.options.empty? ? {} : { options: interaction.request.options}
  hash[:request] = interaction.request.as_json.merge(options)
  hash[:response] = Reification.from_term(interaction.response)
  hash
end

#to_json(opts = {}) ⇒ Object



27
28
29
# File 'lib/pact/consumer/mock_service_interaction_expectation.rb', line 27

def to_json opts = {}
  as_json.to_json(opts)
end