@@ -12,18 +12,19 @@ module Pact::MockService
12
12
end
13
13
14
14
let ( :name ) { 'some_service' }
15
+ let ( :options ) { { pact_specification_version : '3' } }
15
16
16
17
context "for http://localhost" do
17
18
let ( :url ) { 'http://localhost:1234' }
18
19
19
20
it "starts a mock service at the given port on localhost" do
20
21
expect_any_instance_of ( AppRegistration ) . to receive ( :spawn )
21
- AppManager . instance . register_mock_service_for name , url
22
+ AppManager . instance . register_mock_service_for name , url , options
22
23
AppManager . instance . spawn_all
23
24
end
24
25
25
26
it "registers the mock service as running on the given port" do
26
- AppManager . instance . register_mock_service_for name , url
27
+ AppManager . instance . register_mock_service_for name , url , options
27
28
expect ( AppManager . instance . app_registered_on? ( 1234 ) ) . to eq true
28
29
end
29
30
@@ -32,37 +33,41 @@ module Pact::MockService
32
33
expect ( Pact ::MockService ) . to receive ( :new ) do | options |
33
34
expect ( options [ :pact_dir ] ) . to eq 'pact_dir'
34
35
end
35
- AppManager . instance . register_mock_service_for name , url
36
+ AppManager . instance . register_mock_service_for name , url , options
36
37
end
37
38
38
39
it "passes in the pact_specification_verson to the MockService" do
39
40
expect ( Pact ::MockService ) . to receive ( :new ) . with ( hash_including ( pact_specification_version : '3' ) ) . and_call_original
40
- AppManager . instance . register_mock_service_for name , url , pact_specification_version : '3'
41
+ AppManager . instance . register_mock_service_for name , url , options
41
42
end
42
43
end
43
44
44
45
context "for https://" do
45
46
let ( :url ) { 'https://localhost:1234' }
46
47
47
48
it "should throw an unsupported error" do
48
- expect { AppManager . instance . register_mock_service_for name , url } . to raise_error "Currently only http is supported"
49
+ expect { AppManager . instance . register_mock_service_for name , url , options } . to raise_error "Currently only http is supported"
49
50
end
50
51
end
51
52
52
53
context "for a host other than localhost" do
53
54
let ( :url ) { 'http://aserver:1234' }
54
55
55
56
it "should throw an unsupported error" do
56
- expect { AppManager . instance . register_mock_service_for name , url } . to raise_error "Currently only services on localhost are supported"
57
+ expect { AppManager . instance . register_mock_service_for name , url , options } . to raise_error "Currently only services on localhost are supported"
57
58
end
58
59
end
59
60
60
61
describe "find_a_port option" do
61
62
let ( :url ) { 'http://localhost' }
62
63
64
+ before do
65
+ options [ :find_available_port ] = true
66
+ end
67
+
63
68
it "builds AppRegistration with `nil` port" do
64
69
expect ( AppRegistration ) . to receive ( :new ) . with ( hash_including ( port : nil ) ) . and_call_original
65
- AppManager . instance . register_mock_service_for name , url , find_available_port : true
70
+ AppManager . instance . register_mock_service_for name , url , options
66
71
end
67
72
end
68
73
end
0 commit comments