@@ -25,6 +25,7 @@ module Selenium
25
25
let ( :mock_process ) { instance_double ( WebDriver ::ChildProcess ) . as_null_object }
26
26
let ( :mock_poller ) { instance_double ( WebDriver ::SocketPoller , connected? : true , closed? : true ) }
27
27
let ( :repo ) { 'https://api.github.com/repos/seleniumhq/selenium/releases' }
28
+ let ( :port ) { WebDriver ::PortProber . above ( 4444 ) }
28
29
let ( :example_json ) do
29
30
[ { url : "#{ repo } /41272273" ,
30
31
assets : {
@@ -62,28 +63,28 @@ module Selenium
62
63
it 'waits for the server process by default' do
63
64
allow ( File ) . to receive ( :exist? ) . with ( 'selenium_server_deploy.jar' ) . and_return ( true )
64
65
allow ( WebDriver ::ChildProcess ) . to receive ( :build )
65
- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , '4444' )
66
+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s )
66
67
. and_return ( mock_process )
67
68
68
- server = described_class . new ( 'selenium_server_deploy.jar' )
69
+ server = described_class . new ( 'selenium_server_deploy.jar' , port : port )
69
70
allow ( server ) . to receive ( :socket ) . and_return ( mock_poller )
70
71
allow ( mock_process ) . to receive ( :wait )
71
72
72
73
server . start
73
74
74
75
expect ( File ) . to have_received ( :exist? ) . with ( 'selenium_server_deploy.jar' )
75
76
expect ( WebDriver ::ChildProcess ) . to have_received ( :build )
76
- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , '4444' )
77
+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s )
77
78
expect ( mock_process ) . to have_received ( :wait )
78
79
end
79
80
80
81
it 'adds additional args' do
81
82
allow ( File ) . to receive ( :exist? ) . with ( 'selenium_server_deploy.jar' ) . and_return ( true )
82
83
allow ( WebDriver ::ChildProcess ) . to receive ( :build )
83
- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , '4444' , 'foo' , 'bar' )
84
+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s , 'foo' , 'bar' )
84
85
. and_return ( mock_process )
85
86
86
- server = described_class . new ( 'selenium_server_deploy.jar' , background : true )
87
+ server = described_class . new ( 'selenium_server_deploy.jar' , port : port , background : true )
87
88
allow ( server ) . to receive ( :socket ) . and_return ( mock_poller )
88
89
89
90
server << %w[ foo bar ]
@@ -92,7 +93,7 @@ module Selenium
92
93
expect ( File ) . to have_received ( :exist? ) . with ( 'selenium_server_deploy.jar' )
93
94
expect ( WebDriver ::ChildProcess ) . to have_received ( :build )
94
95
. with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' ,
95
- '--port' , '4444' , 'foo' , 'bar' )
96
+ '--port' , port . to_s , 'foo' , 'bar' )
96
97
end
97
98
98
99
it 'adds additional JAVA options args' do
@@ -102,7 +103,7 @@ module Selenium
102
103
'-Dwebdriver.chrome.driver=/bin/chromedriver' ,
103
104
'-jar' , 'selenium_server_deploy.jar' ,
104
105
'standalone' ,
105
- '--port' , '4444' ,
106
+ '--port' , port . to_s ,
106
107
'foo' ,
107
108
'bar' )
108
109
. and_return ( mock_process )
@@ -120,7 +121,7 @@ module Selenium
120
121
'-Dwebdriver.chrome.driver=/bin/chromedriver' ,
121
122
'-jar' , 'selenium_server_deploy.jar' ,
122
123
'standalone' ,
123
- '--port' , '4444' ,
124
+ '--port' , port . to_s ,
124
125
'foo' ,
125
126
'bar' )
126
127
end
@@ -206,7 +207,7 @@ module Selenium
206
207
it 'sets options after instantiation' do
207
208
allow ( File ) . to receive ( :exist? ) . with ( 'selenium_server_deploy.jar' ) . and_return ( true )
208
209
server = described_class . new ( 'selenium_server_deploy.jar' )
209
- expect ( server . port ) . to eq ( 4444 )
210
+ expect ( server . port ) . to eq ( port )
210
211
expect ( server . timeout ) . to eq ( 30 )
211
212
expect ( server . background ) . to be false
212
213
expect ( server . log ) . to be_nil
0 commit comments