From 3bfd399dad9e00733ee2ccfdc9a6f263ac8d8c3b Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Sat, 15 Jun 2024 22:22:29 +0100 Subject: [PATCH] test: upgrade to rack 3.x and add workaround to rack 3.1.x related: https://github.com/pact-foundation/pact-mock_service/pull/152 --- .github/workflows/test.yml | 3 +++ Gemfile | 7 ++++++- spec/support/ssl_server.rb | 15 ++++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 10e3c32..7a65cfb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,9 @@ jobs: matrix: ruby_version: ["2.7", "3.0", "3.1", "3.2", "3.3"] os: ["ubuntu-latest","windows-latest","macos-latest"] + rack_version: ["2", "3"] + env: + RACK_VERSION: ${{ matrix.rack_version }} steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 diff --git a/Gemfile b/Gemfile index f5988e7..a950be7 100644 --- a/Gemfile +++ b/Gemfile @@ -25,5 +25,10 @@ end group :test do gem 'faraday', '~>2.0' gem 'faraday-retry', '~>2.0' - gem 'rackup', '~> 2.1' + if ENV['RACK_VERSION'] == '2' + gem 'rack', '>= 2.0', '< 3.0' + else + gem 'rack', '>= 2.0' + gem 'rackup', '~> 2.1' + end end diff --git a/spec/support/ssl_server.rb b/spec/support/ssl_server.rb index b8bbed8..c9ef91c 100644 --- a/spec/support/ssl_server.rb +++ b/spec/support/ssl_server.rb @@ -32,11 +32,16 @@ def webrick_opts port require "webrick" require "webrick/https" require "rack" - require "rackup/handler/webrick" - - opts = webrick_opts(4444) - - Rack::Handler::WEBrick.run(app, **opts) do |server| + begin + require 'rackup/handler/webrick' + opts = webrick_opts(4444) + PactWEBrick = Rackup::Handler::WEBrick + rescue LoadError + require 'rack/handler/webrick' + PactWEBrick = Rack::Handler::WEBrick + opts = webrick_opts(4444) + end + server = PactWEBrick.run(app, **opts) do |server| @server = server end end