1818# under the License.
1919
2020require File . expand_path ( 'webdriver/spec_helper' , __dir__ )
21- require 'etc'
2221require 'selenium/server'
2322
2423module Selenium
2524 describe Server do
26- let ( :mock_process ) do
27- instance_double ( WebDriver ::ChildProcess ) . tap do |mock |
28- allow ( mock ) . to receive ( :start )
29- allow ( mock ) . to receive ( :wait )
30- allow ( mock ) . to receive ( :stop )
31- allow ( mock ) . to receive ( :detach= )
32- allow ( mock ) . to receive ( :io )
33- allow ( mock ) . to receive ( :io= )
34- end
35- end
25+ let ( :mock_process ) { instance_double ( WebDriver ::ChildProcess ) . as_null_object }
3626 let ( :mock_poller ) { instance_double ( WebDriver ::SocketPoller , connected? : true , closed? : true ) }
3727 let ( :repo ) { 'https://api.github.com/repos/seleniumhq/selenium/releases' }
3828 let ( :port ) { WebDriver ::PortProber . above ( 4444 ) }
@@ -58,8 +48,7 @@ module Selenium
5848 it 'uses the given jar file and port' do
5949 allow ( File ) . to receive ( :exist? ) . with ( 'selenium_server_deploy.jar' ) . and_return ( true )
6050 allow ( WebDriver ::ChildProcess ) . to receive ( :build )
61- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , '1234' ,
62- '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s )
51+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , '1234' )
6352 . and_return ( mock_process )
6453
6554 server = described_class . new ( 'selenium_server_deploy.jar' , port : 1234 , background : true )
@@ -68,15 +57,13 @@ module Selenium
6857 server . start
6958 expect ( File ) . to have_received ( :exist? ) . with ( 'selenium_server_deploy.jar' )
7059 expect ( WebDriver ::ChildProcess ) . to have_received ( :build )
71- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , '1234' ,
72- '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s )
60+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , '1234' )
7361 end
7462
7563 it 'waits for the server process by default' do
7664 allow ( File ) . to receive ( :exist? ) . with ( 'selenium_server_deploy.jar' ) . and_return ( true )
7765 allow ( WebDriver ::ChildProcess ) . to receive ( :build )
78- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s ,
79- '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s )
66+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s )
8067 . and_return ( mock_process )
8168
8269 server = described_class . new ( 'selenium_server_deploy.jar' , port : port )
@@ -87,16 +74,14 @@ module Selenium
8774
8875 expect ( File ) . to have_received ( :exist? ) . with ( 'selenium_server_deploy.jar' )
8976 expect ( WebDriver ::ChildProcess ) . to have_received ( :build )
90- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s ,
91- '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s )
77+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s )
9278 expect ( mock_process ) . to have_received ( :wait )
9379 end
9480
9581 it 'adds additional args' do
9682 allow ( File ) . to receive ( :exist? ) . with ( 'selenium_server_deploy.jar' ) . and_return ( true )
9783 allow ( WebDriver ::ChildProcess ) . to receive ( :build )
98- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s ,
99- '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s , 'foo' , 'bar' )
84+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s , 'foo' , 'bar' )
10085 . and_return ( mock_process )
10186
10287 server = described_class . new ( 'selenium_server_deploy.jar' , port : port , background : true )
@@ -108,8 +93,7 @@ module Selenium
10893 expect ( File ) . to have_received ( :exist? ) . with ( 'selenium_server_deploy.jar' )
10994 expect ( WebDriver ::ChildProcess ) . to have_received ( :build )
11095 . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' ,
111- '--port' , port . to_s , '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s ,
112- 'foo' , 'bar' )
96+ '--port' , port . to_s , 'foo' , 'bar' )
11397 end
11498
11599 it 'adds additional JAVA options args' do
@@ -120,8 +104,6 @@ module Selenium
120104 '-jar' , 'selenium_server_deploy.jar' ,
121105 'standalone' ,
122106 '--port' , port . to_s ,
123- '--override-max-sessions' , 'true' ,
124- '--max-sessions' , Etc . nprocessors . to_s ,
125107 'foo' ,
126108 'bar' )
127109 . and_return ( mock_process )
@@ -140,8 +122,6 @@ module Selenium
140122 '-jar' , 'selenium_server_deploy.jar' ,
141123 'standalone' ,
142124 '--port' , port . to_s ,
143- '--override-max-sessions' , 'true' ,
144- '--max-sessions' , Etc . nprocessors . to_s ,
145125 'foo' ,
146126 'bar' )
147127 end
@@ -214,8 +194,7 @@ module Selenium
214194 it 'raises Selenium::Server::Error if the server is not launched within the timeout' do
215195 allow ( File ) . to receive ( :exist? ) . with ( 'selenium_server_deploy.jar' ) . and_return ( true )
216196 allow ( WebDriver ::ChildProcess ) . to receive ( :build )
217- . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s ,
218- '--override-max-sessions' , 'true' , '--max-sessions' , Etc . nprocessors . to_s )
197+ . with ( 'java' , '-jar' , 'selenium_server_deploy.jar' , 'standalone' , '--port' , port . to_s )
219198 . and_return ( mock_process )
220199
221200 poller = instance_double ( WebDriver ::SocketPoller )
0 commit comments