Skip to content

Commit d576b4c

Browse files
authored
Merge pull request #141 from YOU54F/ruby_3_1
Ruby 3 1
2 parents c51b79c + be1dfca commit d576b4c

22 files changed

+145
-103
lines changed

.github/workflows/release_gem.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
- uses: actions/checkout@v3
1414
- uses: ruby/setup-ruby@v1
1515
with:
16-
ruby-version: '2.7'
16+
ruby-version: '3.1'
1717
- run: "bundle install"
18-
# - name: Test
19-
# run: bundle exec rake
18+
- name: Test
19+
run: bundle exec rake
2020

2121
release:
2222
needs: test

.github/workflows/test.yml.hangs .github/workflows/test.yml

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ on: [push, pull_request]
44

55
jobs:
66
test:
7-
runs-on: "ubuntu-latest"
8-
continue-on-error: ${{ matrix.experimental }}
97
strategy:
108
fail-fast: false
119
matrix:
12-
ruby_version: ["2.2", "2.7"]
13-
experimental: [false]
14-
include:
15-
- ruby_version: "3.0"
16-
experimental: true
10+
ruby_version: ["2.7","3.0","3.1"]
11+
os: ["ubuntu-latest","windows-latest","macos-latest"]
12+
runs-on: ${{ matrix.os }}
1713
steps:
1814
- uses: actions/checkout@v2
1915
- uses: ruby/setup-ruby@v1

lib/pact/mock_service/interactions/interaction_mismatch.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def to_hash
5656
def to_s
5757
[
5858
"Diff with interaction: #{candidate_interaction.description_with_provider_state_quoted}",
59-
diff_formatter.call(diff, {colour: false})
59+
diff_formatter.call(diff, **{colour: false})
6060
].join("\n")
6161
end
6262

pact-mock_service.gemspec

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ Gem::Specification.new do |gem|
2626
gem.add_runtime_dependency 'thor', '>= 0.19', '< 2.0'
2727
gem.add_runtime_dependency 'json'
2828
gem.add_runtime_dependency 'webrick', '~> 1.3'
29-
gem.add_runtime_dependency 'term-ansicolor', '~> 1.0'
3029
gem.add_runtime_dependency 'pact-support', '~> 1.16', '>= 1.16.4'
3130
gem.add_runtime_dependency 'filelock', '~> 1.1'
3231

3332
gem.add_development_dependency 'rack-test', '~> 0.7'
3433
gem.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1'
3534
gem.add_development_dependency 'webmock', '~> 3.4'
3635
gem.add_development_dependency 'pry'
37-
gem.add_development_dependency 'fakefs', '~> 0.4'
36+
gem.add_development_dependency 'fakefs', '~> 2.4'
3837
gem.add_development_dependency 'hashie', '~> 2.0'
3938
gem.add_development_dependency 'activesupport', '~> 5.1'
4039
gem.add_development_dependency 'faraday', '~> 0.12'

spec/features/administration_endpoints_cors_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@
108108

109109
context "when the Origin header is set" do
110110
it "sets the Access-Control-Allow-Origin header to be the Origin" do
111-
options '/pact', nil, { 'HTTP_ACCESS_CONTROL_REQUEST_HEADERS' => 'X-Pact-Mock-Service, Content-Type', 'HTTP_ORIGIN' => 'http://localhost:1234' }
112-
expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://localhost:1234'
111+
options '/pact', nil, { 'HTTP_ACCESS_CONTROL_REQUEST_HEADERS' => 'X-Pact-Mock-Service, Content-Type', 'HTTP_ORIGIN' => 'http://localhost:8888' }
112+
expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://localhost:8888'
113113
end
114114
end
115115
end

spec/features/log/mock_multiple_responses_spec.log

+2
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,10 @@ Missing requests:
209209
GET /alligators
210210

211211

212+
212213
WARN -- : Missing requests:
213214
GET /alligators
214215
GET /alligators
215216

216217

218+

spec/features/log/mock_one_response_spec.log

+36
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,44 @@ WARN -- : Verifying - actual interactions do not match expected interactions for
111111
Incorrect requests:
112112
GET /alligators (request headers did not match)
113113

114+
Diff with interaction: "a request for alligators" given "alligators exist"
115+
Diff
116+
--------------------------------------
117+
Key: - is expected
118+
+ is actual
119+
Matching keys and values are not shown
120+
121+
{
122+
"headers": {
123+
- "Accept": "application/json"
124+
+ "Accept": "application/xml"
125+
}
126+
}
127+
128+
Description of differences
129+
--------------------------------------
130+
* Expected "application/json" but got "application/xml" at $.headers.Accept
131+
114132

115133
WARN -- : Incorrect requests:
116134
GET /alligators (request headers did not match)
117135

136+
Diff with interaction: "a request for alligators" given "alligators exist"
137+
Diff
138+
--------------------------------------
139+
Key: - is expected
140+
+ is actual
141+
Matching keys and values are not shown
142+
143+
{
144+
"headers": {
145+
- "Accept": "application/json"
146+
+ "Accept": "application/xml"
147+
}
148+
}
149+
150+
Description of differences
151+
--------------------------------------
152+
* Expected "application/json" but got "application/xml" at $.headers.Accept
153+
118154

spec/features/mock_interactions_with_cors_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,21 @@
5656
expect(last_response.status).to be 200
5757

5858
# OPTIONS request from the browser for the request under test
59-
options '/alligators/new', nil, { 'HTTP_ACCESS_CONTROL_REQUEST_HEADERS' => 'accept', 'HTTP_ORIGIN' => 'http://localhost:1234' }
59+
options '/alligators/new', nil, { 'HTTP_ACCESS_CONTROL_REQUEST_HEADERS' => 'accept', 'HTTP_ORIGIN' => 'http://localhost:8888' }
6060

6161
# Ensure it allows the browser to actually make the request
6262
expect(last_response.status).to eq 200
63-
expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://localhost:1234'
63+
expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://localhost:8888'
6464
expect(last_response.headers['Access-Control-Allow-Credentials']).to eq 'true'
6565
expect(last_response.headers['Access-Control-Allow-Headers']).to include 'accept'
6666
expect(last_response.headers['Access-Control-Allow-Methods']).to include "DELETE, POST, GET, HEAD, PUT, TRACE, CONNECT"
6767

6868
# Make the request
69-
post "/alligators/new", actual_request, { 'HTTP_ACCEPT' => 'application/json', 'HTTP_ORIGIN' => 'http://localhost:1234' }
69+
post "/alligators/new", actual_request, { 'HTTP_ACCEPT' => 'application/json', 'HTTP_ORIGIN' => 'http://localhost:8888' }
7070

7171
# Ensure that the response we get back was the one we expected
7272
# and includes the CORS header
73-
expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://localhost:1234'
73+
expect(last_response.headers['Access-Control-Allow-Origin']).to eq 'http://localhost:8888'
7474
expect(last_response.headers['Content-Type']).to eq 'application/json'
7575
expect(JSON.parse(last_response.body)).to eq([{ 'name' => 'Mary' }])
7676
end

spec/integration/cli_cors_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
require 'fileutils'
33
require 'support/integration_spec_support'
44

5-
describe "The pact-mock-service command line interface", mri_only: true do
5+
describe "The pact-mock-service command line interface", mri_only: true, skip_windows: true do
66

77
include Pact::IntegrationTestSupport
88

99
before :all do
1010
clear_dirs
11-
@pid = start_server 1234, '--cors'
11+
@pid = start_server 8888, '--cors'
1212
end
1313

1414
it "responds to an OPTIONS request for a non administration request" do
15-
response = make_options_request 1234
15+
response = make_options_request 8888
1616
expect(response.status).to eq 200
1717
expect(response.headers['Access-Control-Allow-Headers']).to_not be nil
1818
end

spec/integration/cli_monkeypatch_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require 'support/integration_spec_support'
33
require 'find_a_port'
44

5-
describe "The pact-mock-service command line interface with a monkeypatch", mri_only: true do
5+
describe "The pact-mock-service command line interface with a monkeypatch", mri_only: true, skip_windows: true do
66

77
include Pact::IntegrationTestSupport
88

spec/integration/cli_spec.rb

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
11
require 'fileutils'
22
require 'support/integration_spec_support'
33

4-
describe "The pact-mock-service command line interface", mri_only: true do
4+
describe "The pact-mock-service command line interface", mri_only: true, skip_windows: true do
55

66
include Pact::IntegrationTestSupport
77

88
before :all do
99
clear_dirs
10-
@pid = start_server 1234, "--pact-specification-version 3.0.0"
10+
@pid = start_server 8888, "--pact-specification-version 3.0.0"
1111
end
1212

1313
it "starts up and responds with mocked responses" do
14-
response = setup_interaction 1234
14+
response = setup_interaction 8888
1515
expect(response.status).to eq 200
1616

17-
response = invoke_expected_request 1234
17+
response = invoke_expected_request 8888
1818
puts response.body if response.status != 200
1919
expect(response.status).to eq 200
2020
expect(response.body).to eq 'Hello world'
2121

22-
write_pact 1234
22+
write_pact 8888
2323
expect(response.status).to eq 200
2424
end
2525

2626
it "respects headers with underscores" do
27-
setup_interaction_with_underscored_header 1234
28-
response = invoke_request_with_underscored_header 1234
27+
setup_interaction_with_underscored_header 8888
28+
response = invoke_request_with_underscored_header 8888
2929
puts response.body unless response.status == 200
3030
expect(response.status).to eq 200
3131
end
3232

3333
it "sets the X-Pact-Mock-Service-Location header" do
34-
response = setup_interaction 1234
35-
expect(response.headers['X-Pact-Mock-Service-Location']).to eq 'http://0.0.0.0:1234'
34+
response = setup_interaction 8888
35+
expect(response.headers['X-Pact-Mock-Service-Location']).to eq 'http://0.0.0.0:8888'
3636
end
3737

3838
it "writes logs to the specified log file" do
3939
expect(File.exist?('tmp/integration.log')).to be true
4040
end
4141

4242
it "writes the pact to the specified directory" do
43-
clear_interactions 1234
44-
setup_interaction 1234
45-
invoke_expected_request 1234
43+
clear_interactions 8888
44+
setup_interaction 8888
45+
invoke_expected_request 8888
4646
expect(File.exist?('tmp/pacts/consumer-provider.json')).to be true
4747
end
4848

4949
it "sets the pact specification version" do
50-
clear_interactions 1234
51-
setup_interaction 1234
52-
invoke_expected_request 1234
50+
clear_interactions 8888
51+
setup_interaction 8888
52+
invoke_expected_request 8888
5353

54-
write_pact 1234
54+
write_pact 8888
5555
expect(File.read("tmp/pacts/consumer-provider.json")).to include "3.0.0"
5656
end
5757

spec/integration/cli_ssl_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'fileutils'
22
require 'support/integration_spec_support'
33

4-
describe "The pact-mock-service command line interface, with SSL", mri_only: true, skip_travis: true do
4+
describe "The pact-mock-service command line interface, with SSL", mri_only: true, skip_travis: true, skip_windows: true, skip_gha_linux: true do
55

66
include Pact::IntegrationTestSupport
77

spec/integration/cli_with_auto_pact_write_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require 'support/integration_spec_support'
33
require 'find_a_port'
44

5-
describe "The pact-mock-service command line interface", mri_only: true do
5+
describe "The pact-mock-service command line interface", mri_only: true, skip_windows: true do
66

77
include Pact::IntegrationTestSupport
88

spec/integration/control_server_cli_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ def mock_service_headers
1616
end
1717
end
1818

19-
describe "The pact-mock-service control server command line interface", mri_only: true do
19+
describe "The pact-mock-service control server command line interface", mri_only: true, skip_windows: true do
2020

2121
include Pact::ControlServerTestSupport
2222

2323
before :all do
2424
clear_dirs
25-
@pid = start_control 1234, "--pact-specification-version 3"
25+
@pid = start_control 8888, "--pact-specification-version 3"
2626
end
2727

2828
it "starts up and responds with mocked responses" do
29-
response = setup_interaction 1234
29+
response = setup_interaction 8888
3030
puts response.body unless response.status == 200
3131
expect(response.status).to eq 200
3232
mock_service_port = URI(response.headers['X-Pact-Mock-Service-Location']).port
33-
expect(mock_service_port).to_not eq 1234
33+
expect(mock_service_port).to_not eq 8888
3434

3535
response = invoke_expected_request mock_service_port
3636
expect(response.status).to eq 200

spec/integration/control_server_with_cors_cli_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
require 'fileutils'
22
require 'support/integration_spec_support'
33

4-
describe "The pact-mock-service control server command line interface", mri_only: true do
4+
describe "The pact-mock-service control server command line interface", mri_only: true, skip_windows: true do
55

66
include Pact::ControlServerTestSupport
77

88
before :all do
99
clear_dirs
10-
@pid = start_control 1234, '--cors'
10+
@pid = start_control 8888, '--cors'
1111
end
1212

1313
it "responds to an OPTIONS request for a non administration request" do
14-
response = setup_interaction 1234
14+
response = setup_interaction 8888
1515
expect(response.status).to eq 200
1616
mock_service_port = URI(response.headers['X-Pact-Mock-Service-Location']).port
1717

spec/integration/control_server_with_ssl_cli_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
require 'fileutils'
22
require 'support/integration_spec_support'
33

4-
describe "The pact-mock-service control server command line interface", mri_only: true do
4+
describe "The pact-mock-service control server command line interface", mri_only: true, skip_windows: true do
55

66
include Pact::ControlServerTestSupport
77

88
before :all do
99
clear_dirs
10-
@pid = start_control 1234, '--ssl'
10+
@pid = start_control 8888, '--ssl'
1111
end
1212

1313
it "sets the X-Pact-Mock-Service-Location with https" do
14-
response = setup_interaction 1234
14+
response = setup_interaction 8888
1515
expect(response.headers['X-Pact-Mock-Service-Location']).to start_with 'https://localhost:'
1616
end
1717

1818
it "responds to an OPTIONS request for a non administration request" do
19-
response = setup_interaction 1234
19+
response = setup_interaction 8888
2020
expect(response.status).to eq 200
2121
mock_service_port = URI(response.headers['X-Pact-Mock-Service-Location']).port
2222
response = connect_via_ssl mock_service_port

spec/integration/stub_cli_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'support/integration_spec_support'
22

3-
describe "The pact-stub-service command line interface", mri_only: true do
3+
describe "The pact-stub-service command line interface", mri_only: true, skip_windows: true do
44

55
include Pact::IntegrationTestSupport
66

spec/integration/stub_cli_with_multiple_pacts_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'support/integration_spec_support'
22
require 'find_a_port'
33

4-
describe "The pact-stub-service command line interface with multiple pacts", mri_only: true do
4+
describe "The pact-stub-service command line interface with multiple pacts", mri_only: true, skip_windows: true do
55

66
include Pact::IntegrationTestSupport
77

spec/lib/pact/mock_service/app_manager_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module Pact::MockService
1717
let(:options) { { pact_specification_version: '3' } }
1818

1919
context "for http://localhost" do
20-
let(:url) { 'http://localhost:1234'}
20+
let(:url) { 'http://localhost:8888'}
2121

2222
it "starts a mock service at the given port on localhost" do
2323
expect_any_instance_of(AppRegistration).to receive(:spawn)
@@ -27,7 +27,7 @@ module Pact::MockService
2727

2828
it "registers the mock service as running on the given port" do
2929
AppManager.instance.register_mock_service_for name, url, options
30-
expect(AppManager.instance.app_registered_on?(1234)).to eq true
30+
expect(AppManager.instance.app_registered_on?(8888)).to eq true
3131
end
3232

3333
it "reports the metric for pact mock service started" do
@@ -50,7 +50,7 @@ module Pact::MockService
5050
end
5151

5252
context "for https://" do
53-
let(:url) { 'https://localhost:1234'}
53+
let(:url) { 'https://localhost:8888'}
5454

5555
it "should throw an unsupported error" do
5656
expect { AppManager.instance.register_mock_service_for name, url, options }.to raise_error "Currently only http is supported"

0 commit comments

Comments
 (0)