Sha256: 1dee503cfa1e0aca13eb59b267bc520a2533070b3cfdf038256ce212c17dabdb

Contents?: true

Size: 1.7 KB

Versions: 7

Compression:

Stored size: 1.7 KB

Contents

require 'pact/provider/rspec'

require 'flapjack/configuration'
require 'flapjack/gateways/jsonapi'

require './spec/service_consumers/provider_states_for_flapjack-diner.rb'

FLAPJACK_ENV    = ENV["FLAPJACK_ENV"] || 'test'
FLAPJACK_ROOT   = File.join(File.dirname(__FILE__), '..')
FLAPJACK_CONFIG = File.join(FLAPJACK_ROOT, 'etc', 'flapjack_config.yaml')
ENV['RACK_ENV'] = ENV["FLAPJACK_ENV"]

require 'bundler'
Bundler.require(:default, :test)

class MockLogger
  attr_accessor :messages

  def initialize
    @messages = []
  end

  %w(debug info warn error fatal).each do |level|
    class_eval <<-RUBY
      def #{level}?
        true
      end

      def #{level}(msg)
        @messages << msg
      end
    RUBY
  end
end

Flapjack::Gateways::JSONAPI.instance_variable_get('@middleware').delete_if {|m|
  m[0] == Rack::FiberPool
}

Flapjack::Gateways::JSONAPI.class_eval do
  set :show_exceptions, false
  set :raise_errors, false
  error do
    Flapjack::Gateways::JSONAPI.instance_variable_get('@rescue_exception').
      call(env, env['sinatra.error'])
  end
end

cfg = Flapjack::Configuration.new
$redis_options = cfg.load(FLAPJACK_CONFIG) ?
                 cfg.for_redis :
                 {:db => 14, :driver => :ruby}

Flapjack::Gateways::JSONAPI.instance_variable_set('@config', 'port' => 19081)

Flapjack::Gateways::JSONAPI.instance_variable_set('@redis_config', $redis_options)
Flapjack::Gateways::JSONAPI.instance_variable_set('@logger', MockLogger.new)

Flapjack::Gateways::JSONAPI.start

Pact.configure do |config|

end

Pact.service_provider "flapjack" do

  app { Flapjack::Gateways::JSONAPI.new }

  honours_pact_with 'flapjack-diner' do
    pact_uri './spec/service_consumers/pacts/flapjack-diner_v1.0.json'
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
flapjack-1.6.0 spec/service_consumers/pact_helper.rb
flapjack-1.6.0rc4 spec/service_consumers/pact_helper.rb
flapjack-1.6.0rc3 spec/service_consumers/pact_helper.rb
flapjack-1.6.0rc2 spec/service_consumers/pact_helper.rb
flapjack-1.6.0rc1 spec/service_consumers/pact_helper.rb
flapjack-1.5.0 spec/service_consumers/pact_helper.rb
flapjack-1.5.0rc1 spec/service_consumers/pact_helper.rb