Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: support Rack 2 & 3 #122

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ on: [push, pull_request]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ruby_version: ["2.7", "3.0", "3.1", "3.2", "3.3"]
os: ["ubuntu-latest","windows-latest","macos-latest"]
rack_version: ["2", "3"]
runs-on: ${{ matrix.os }}
env:
RACK_VERSION: ${{ matrix.rack_version }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
- run: "bundle install"
- run: "bundle exec rake"
- run: "bundle exec rake"
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions examples/Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://rubygems.org'

gem 'sinatra', '>= 3.1.0'
gem 'sinatra-contrib', '>= 3.1.0'
gem 'pact-provider-verifier', '>= 1.38.0'
gem 'sinatra', '>= 4.0.0'
gem 'sinatra-contrib', '>= 4.0.0'
gem 'pact-provider-verifier', '>= 1.38.0', path: '../../pact-provider-verifier'
93 changes: 56 additions & 37 deletions examples/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
PATH
remote: ..
specs:
pact-provider-verifier (1.38.0)
faraday (~> 2.5)
faraday-retry (~> 2.2)
json (> 1.8)
pact (~> 1.59)
pact-message (~> 0.5)
rack (>= 3.0, < 4.0)
rack-reverse-proxy
rackup (~> 2.0)
rspec (~> 3.5)
rspec_junit_formatter (~> 0.3)

GEM
remote: https://rubygems.org/
specs:
awesome_print (1.9.2)
base64 (0.2.0)
bigdecimal (3.1.8)
diff-lcs (1.5.1)
expgen (0.1.1)
parslet
faraday (2.8.1)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
faraday-retry (2.2.0)
faraday (2.10.1)
faraday-net_http (>= 2.0, < 3.2)
logger
faraday-net_http (3.1.1)
net-http
faraday-retry (2.2.1)
faraday (~> 2.0)
find_a_port (1.0.1)
json (2.7.2)
logger (1.6.0)
multi_json (1.15.0)
mustermann (3.0.0)
mustermann (3.0.1)
ruby2_keywords (~> 0.0.1)
net-http (0.4.1)
uri
pact (1.64.0)
pact-mock_service (~> 3.0, >= 3.3.1)
pact-support (~> 1.16, >= 1.16.9)
Expand All @@ -30,85 +49,85 @@ GEM
pact-mock_service (~> 3.1)
pact-support (~> 1.8)
thor (>= 0.20, < 2.0)
pact-mock_service (3.11.2)
pact-mock_service (3.12.2)
find_a_port (~> 1.0.1)
json
pact-support (~> 1.16, >= 1.16.4)
rack (~> 2.0)
rack (>= 3.0, < 4.0)
rackup (~> 2.0)
rspec (>= 2.14)
thor (>= 0.19, < 2.0)
webrick (~> 1.8)
pact-provider-verifier (1.38.0)
faraday (~> 2.5)
faraday-retry (~> 2.2)
json (> 1.8)
pact (~> 1.59)
pact-message (~> 0.5)
rack (~> 2.1)
rack-reverse-proxy
rspec (~> 3.5)
rspec_junit_formatter (~> 0.3)
pact-support (1.20.0)
awesome_print (~> 1.9)
diff-lcs (~> 1.5)
expgen (~> 0.1)
rainbow (~> 3.1.1)
parslet (2.0.0)
rack (2.2.9)
rack-protection (3.2.0)
rack (3.1.7)
rack-protection (4.0.0)
base64 (>= 0.1.0)
rack (~> 2.2, >= 2.2.4)
rack (>= 3.0.0, < 4)
rack-proxy (0.7.7)
rack
rack-reverse-proxy (0.12.0)
rack (>= 1.0.0)
rack-proxy (~> 0.6, >= 0.6.1)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rainbow (3.1.1)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
rspec-expectations (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
ruby2_keywords (0.0.5)
sinatra (3.2.0)
sinatra (4.0.0)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.2.0)
rack (>= 3.0.0, < 4)
rack-protection (= 4.0.0)
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
sinatra-contrib (3.2.0)
sinatra-contrib (4.0.0)
multi_json (>= 0.0.2)
mustermann (~> 3.0)
rack-protection (= 3.2.0)
sinatra (= 3.2.0)
rack-protection (= 4.0.0)
sinatra (= 4.0.0)
tilt (~> 2.0)
sync (0.5.0)
term-ansicolor (1.7.2)
term-ansicolor (1.11.2)
tins (~> 1.0)
thor (1.3.1)
tilt (2.3.0)
tins (1.32.1)
tilt (2.4.0)
tins (1.33.0)
bigdecimal
sync
uri (0.13.0)
webrick (1.8.1)

PLATFORMS
arm64-darwin-23
ruby

DEPENDENCIES
pact-provider-verifier (>= 1.38.0)
sinatra (>= 3.1.0)
sinatra-contrib (>= 3.1.0)
pact-provider-verifier (>= 1.38.0)!
sinatra (>= 4.0.0)
sinatra-contrib (>= 4.0.0)

BUNDLED WITH
2.4.10
2.5.14
8 changes: 7 additions & 1 deletion pact-provider-verifier.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +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', '~> 2.1'
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'

Expand Down
3 changes: 2 additions & 1 deletion spec/support/message_producer_verifier.ru
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# TODO provider states

require 'json'
require 'ostruct'

class Provider
def a_test_message
Expand Down Expand Up @@ -31,7 +32,7 @@ class HttpRequestHandler
request_body = JSON.parse(env['rack.input'].read)
message_descriptor = OpenStruct.new(request_body)
response_body = @message_creator.create(message_descriptor)
[200, {'Content-Type' => 'application/json'}, [response_body.to_json]]
[200, {'content-type' => 'application/json'}, [response_body.to_json]]
end

end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/provider-echo-host.ru
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
}
2 changes: 1 addition & 1 deletion spec/support/provider_with_self_signed_cert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]]}
Expand Down
11 changes: 11 additions & 0 deletions spec/support/webbrick.rb
Original file line number Diff line number Diff line change
@@ -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