File tree 3 files changed +16
-12
lines changed
3 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 1
1
require 'fileutils'
2
2
require 'support/integration_spec_support'
3
+ require 'find_a_port'
3
4
4
5
describe "The pact-mock-service command line interface with a monkeypatch" , mri_only : true do
5
6
6
7
include Pact ::IntegrationTestSupport
7
8
8
9
before :all do
9
10
clear_dirs
10
- @pid = start_server 3234 , "--monkeypatch #{ Dir . pwd } /spec/support/monkeypatch.rb"
11
+ @port = FindAPort . available_port
12
+ @pid = start_server @port , "--monkeypatch #{ Dir . pwd } /spec/support/monkeypatch.rb"
11
13
end
12
14
13
15
let ( :interaction ) do
25
27
end
26
28
27
29
it "starts up and responds with mocked responses" do
28
- response = setup_interaction 3234 , interaction
30
+ response = setup_interaction @port , interaction
29
31
30
- `curl -H 'custom_header: bar' http://localhost:3234 /greeting`
32
+ `curl -H 'custom_header: bar' http://localhost:#{ @port } /greeting`
31
33
32
- response = verify 3234
34
+ response = verify @port
33
35
puts response . body unless response . status == 200
34
36
expect ( response . status ) . to eq 200
35
37
end
Original file line number Diff line number Diff line change 1
1
require 'fileutils'
2
2
require 'support/integration_spec_support'
3
+ require 'find_a_port'
3
4
4
5
describe "The pact-mock-service command line interface" , mri_only : true do
5
6
6
7
include Pact ::IntegrationTestSupport
7
8
8
9
before :all do
9
10
clear_dirs
10
- @pid = start_server 1235 , '--consumer Consumer --provider Provider'
11
+ @port = FindAPort . available_port
12
+ @pid = start_server @port , '--consumer Consumer --provider Provider'
11
13
end
12
14
13
15
context "when the consumer and provider names are provided" do
14
16
it "writes the pact to the specified directory on shutdown" do
15
17
expect ( File . exist? ( 'tmp/pacts/consumer-provider.json' ) ) . to be false
16
- response = setup_interaction 1235
18
+ response = setup_interaction @port
17
19
expect ( response . status ) . to eq 200
18
20
19
- response = invoke_expected_request 1235
21
+ response = invoke_expected_request @port
20
22
expect ( response . status ) . to eq 200
21
23
22
24
Process . kill "INT" , @pid
Original file line number Diff line number Diff line change 1
1
require 'support/integration_spec_support'
2
+ require 'find_a_port'
2
3
3
4
describe "The pact-stub-service command line interface with multiple pacts" , mri_only : true do
4
5
5
6
include Pact ::IntegrationTestSupport
6
7
7
- PORT = 5556
8
-
9
8
before :all do
10
9
clear_dirs
11
- @pid = start_stub_server PORT , "spec/support/pact-for-stub-1.json spec/support/pact-for-stub-2.json"
10
+ @port = FindAPort . available_port
11
+ @pid = start_stub_server @port , "spec/support/pact-for-stub-1.json spec/support/pact-for-stub-2.json"
12
12
end
13
13
14
14
it "includes the interactions from the first pact file" do
15
- response = Faraday . get "http://localhost:#{ PORT } /path1"
15
+ response = Faraday . get "http://localhost:#{ @port } /path1"
16
16
puts response . body if response . status != 200
17
17
expect ( response . status ) . to eq 200
18
18
end
19
19
20
20
it "includes the interactions from the second pact file" do
21
- response = Faraday . get "http://localhost:#{ PORT } /path2"
21
+ response = Faraday . get "http://localhost:#{ @port } /path2"
22
22
puts response . body if response . status != 200
23
23
expect ( response . status ) . to eq 200
24
24
end
You can’t perform that action at this time.
0 commit comments