Sha256: 125ebfe127c2040bd8ca0c612e9a9ec1f6e7a36246168d095e8cba097d85cdfa
Contents?: true
Size: 1.69 KB
Versions: 4
Compression:
Stored size: 1.69 KB
Contents
require 'pact/logging' require 'rack/test' require 'pact/consumer_contract/interaction' require 'pact/provider/provider_state' require 'pact/provider/request' module Pact module Provider module TestMethods include Pact::Logging include Rack::Test::Methods def replay_interaction interaction request = Request::Replayable.new(interaction.request) args = [request.path, request.body, request.headers] logger.debug "Sending #{request.method} with #{args}" self.send(request.method, *args) end def parse_body_from_response rack_response case rack_response.headers['Content-Type'] when /json/ JSON.load(rack_response.body) else rack_response.body end end def set_up_provider_state provider_state_name, consumer if provider_state_name get_provider_state(provider_state_name, consumer).set_up end end def tear_down_provider_state provider_state_name, consumer if provider_state_name get_provider_state(provider_state_name, consumer).tear_down end end def get_provider_state provider_state_name, consumer unless provider_state = ProviderState.get(provider_state_name, :for => consumer) extra = consumer ? " for consumer \"#{consumer}\"" : "" error_msg = <<-eos Could not find a provider state named \"#{provider_state_name}\"#{extra}. Have you required the provider states file for this consumer in your pact_helper.rb? Check the name in the Pact.provider_states_for definition is exactly \"#{consumer}\" eos raise error_msg end provider_state end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pact-1.0.13 | lib/pact/provider/test_methods.rb |
pact-1.0.12 | lib/pact/provider/test_methods.rb |
pact-1.0.11 | lib/pact/provider/test_methods.rb |
pact-1.0.10 | lib/pact/provider/test_methods.rb |