Sha256: b67b338c2a33e52f8e776aad2fbad737a9808650c8f7ba03aaac15129818e742

Contents?: true

Size: 1.89 KB

Versions: 1

Compression:

Stored size: 1.89 KB

Contents

require 'pact/consumer/mock_service/expected_interactions'
require 'pact/consumer/mock_service/actual_interactions'
require 'pact/consumer/mock_service/verified_interactions'
require 'pact/consumer/mock_service/interaction_delete'
require 'pact/consumer/mock_service/interaction_post'
require 'pact/consumer/mock_service/interaction_replay'
require 'pact/consumer/mock_service/missing_interactions_get'
require 'pact/consumer/mock_service/verification_get'
require 'pact/consumer/mock_service/log_get'
require 'pact/consumer/mock_service/pact_post'
require 'pact/consumer/mock_service/index_get'
require 'pact/consumer/mock_service/options'
require 'pact/consumer/request'
require 'pact/support'

module Pact
  module Consumer
    class MockService
      class RequestHandlers
        def initialize name, logger, expected_interactions, actual_interactions, verified_interactions, options
          @handlers = [
            Options.new(name, logger, options[:cors_enabled]),
            MissingInteractionsGet.new(name, logger, expected_interactions, actual_interactions),
            VerificationGet.new(name, logger, expected_interactions, actual_interactions, options[:log_description]),
            InteractionPost.new(name, logger, expected_interactions, verified_interactions),
            InteractionDelete.new(name, logger, expected_interactions, actual_interactions),
            LogGet.new(name, logger),
            PactPost.new(name, logger, verified_interactions, options[:pact_dir], options[:consumer_contract_details]),
            IndexGet.new(name, logger),
            InteractionReplay.new(name, logger, expected_interactions, actual_interactions, verified_interactions, options[:cors_enabled])
          ]
        end

        def call env
          relevant_handler = @handlers.detect { |handler| handler.match? env }
          response = relevant_handler.respond(env)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact-mock_service-0.2.4 lib/pact/consumer/mock_service/request_handlers.rb