diff --git a/Gemfile b/Gemfile index e6cea9d..2f660f2 100644 --- a/Gemfile +++ b/Gemfile @@ -9,3 +9,9 @@ if ENV['X_PACT_DEVELOPMENT'] gem "pact-message", path: '../pact-message-ruby' gem "pact-support", path: '../pact-support' end + +if ENV['RACK_VERSION'] == '2' + gem 'rack-reverse-proxy' +else + gem 'rack-reverse-proxy', git: 'https://github.com/samedi/rack-reverse-proxy.git', ref: '06f21feb6afbbf902969c4f1df219df8f2080387' +end diff --git a/pact-provider-verifier.gemspec b/pact-provider-verifier.gemspec index 35510f7..17eba6b 100644 --- a/pact-provider-verifier.gemspec +++ b/pact-provider-verifier.gemspec @@ -26,9 +26,13 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency 'faraday', '~> 2.5' gem.add_runtime_dependency 'faraday-retry', '~> 2.2' gem.add_runtime_dependency 'json', '>1.8' - gem.add_runtime_dependency 'rack', '>= 3.0', '< 4.0' - gem.add_runtime_dependency 'rackup', '~> 2.0' - + if ENV['RACK_VERSION'] == '2' + gem.add_runtime_dependency 'rack', '>= 2.0', '< 3.0' + else + gem.add_runtime_dependency 'rack', '>= 3.0', '< 4.0' + gem.add_runtime_dependency 'rackup', '~> 2.0' + end + gem.add_runtime_dependency 'rack-reverse-proxy' gem.add_runtime_dependency 'rspec_junit_formatter', '~> 0.3' gem.add_runtime_dependency 'ostruct' diff --git a/spec/support/provider-echo-host.ru b/spec/support/provider-echo-host.ru index 2f07d7f..b9b8d7d 100644 --- a/spec/support/provider-echo-host.ru +++ b/spec/support/provider-echo-host.ru @@ -2,5 +2,5 @@ require 'json' run -> (env) { body = {"Host" => env['HTTP_HOST']}.to_json - [200, {"Content-Type" => "application/json"}, [body]] + [200, {"content-type" => "application/json"}, [body]] } diff --git a/spec/support/provider_with_self_signed_cert.rb b/spec/support/provider_with_self_signed_cert.rb index 1bc9366..44305ba 100644 --- a/spec/support/provider_with_self_signed_cert.rb +++ b/spec/support/provider_with_self_signed_cert.rb @@ -3,7 +3,7 @@ def run_provider_with_self_signed_cert port # trap 'INT' do @server.shutdown end require 'rack' - require 'rack/handler/webrick' + require_relative 'webbrick' require 'webrick/https' webrick_opts = {:Port => port, :SSLEnable => true, :SSLCertName => [%w[CN localhost]]} diff --git a/spec/support/webbrick.rb b/spec/support/webbrick.rb new file mode 100644 index 0000000..be74e33 --- /dev/null +++ b/spec/support/webbrick.rb @@ -0,0 +1,11 @@ +module Rack + module Handler + begin + require 'rack/handler/webrick' + WEBrick = Class.new(Rack::Handler::WEBrick) + rescue LoadError + require 'rackup/handler/webrick' + WEBrick = Class.new(Rackup::Handler::WEBrick) + end + end +end \ No newline at end of file