implemented start and stop selenium server only if the selenium_server_address is nil
This commit is contained in:
parent
0edffe0ac4
commit
e49c341fc0
@ -13,21 +13,22 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.start_selenium_server #:nodoc:
|
def self.start_selenium_server #:nodoc:
|
||||||
remote_control = ::Selenium::RemoteControl::RemoteControl.new("0.0.0.0", 4444, 5)
|
unless Webrat.configuration.selenium_server_address
|
||||||
remote_control.jar_file = File.expand_path(__FILE__ + "../../../../vendor/selenium-server.jar")
|
remote_control = ::Selenium::RemoteControl::RemoteControl.new("0.0.0.0", Webrat.configuration.selenium_server_port, 5)
|
||||||
remote_control.start :background => true
|
remote_control.jar_file = File.expand_path(__FILE__ + "../../../../vendor/selenium-server.jar")
|
||||||
TCPSocket.wait_for_service :host => "0.0.0.0", :port => 4444
|
remote_control.start :background => true
|
||||||
|
end
|
||||||
|
TCPSocket.wait_for_service :host => (Webrat.configuration.selenium_server_address || "0.0.0.0"), :port => Webrat.configuration.selenium_server_port
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.stop_selenium_server #:nodoc:
|
def self.stop_selenium_server #:nodoc:
|
||||||
remote_control = ::Selenium::RemoteControl::RemoteControl.new("0.0.0.0", 4444, 5)
|
::Selenium::RemoteControl::RemoteControl.new("0.0.0.0", Webrat.configuration.selenium_server_port, 5).stop unless Webrat.configuration.selenium_server_address
|
||||||
remote_control.stop
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.start_app_server #:nodoc:
|
def self.start_app_server #:nodoc:
|
||||||
pid_file = File.expand_path(RAILS_ROOT + "/tmp/pids/mongrel_selenium.pid")
|
pid_file = File.expand_path(RAILS_ROOT + "/tmp/pids/mongrel_selenium.pid")
|
||||||
system("mongrel_rails start -d --chdir=#{RAILS_ROOT} --port=#{Webrat.configuration.application_port} --environment=#{Webrat.configuration.application_environment} --pid #{pid_file} &")
|
system("mongrel_rails start -d --chdir=#{RAILS_ROOT} --port=#{Webrat.configuration.application_port} --environment=#{Webrat.configuration.application_environment} --pid #{pid_file} &")
|
||||||
TCPSocket.wait_for_service :host => "0.0.0.0", :port => Webrat.configuration.application_port.to_i
|
TCPSocket.wait_for_service :host => Webrat.configuration.application_address, :port => Webrat.configuration.application_port.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.stop_app_server #:nodoc:
|
def self.stop_app_server #:nodoc:
|
||||||
|
@ -12,8 +12,41 @@ describe Webrat, "Selenium" do
|
|||||||
pid_file = "file"
|
pid_file = "file"
|
||||||
File.should_receive(:expand_path).with(RAILS_ROOT + "/tmp/pids/mongrel_selenium.pid").and_return pid_file
|
File.should_receive(:expand_path).with(RAILS_ROOT + "/tmp/pids/mongrel_selenium.pid").and_return pid_file
|
||||||
Webrat.should_receive(:system).with("mongrel_rails start -d --chdir=#{RAILS_ROOT} --port=#{Webrat.configuration.application_port} --environment=#{Webrat.configuration.application_environment} --pid #{pid_file} &")
|
Webrat.should_receive(:system).with("mongrel_rails start -d --chdir=#{RAILS_ROOT} --port=#{Webrat.configuration.application_port} --environment=#{Webrat.configuration.application_environment} --pid #{pid_file} &")
|
||||||
TCPSocket.should_receive(:wait_for_service).with(:host => "0.0.0.0", :port => Webrat.configuration.application_port.to_i)
|
TCPSocket.should_receive(:wait_for_service).with(:host => Webrat.configuration.application_address, :port => Webrat.configuration.application_port.to_i)
|
||||||
Webrat.start_app_server
|
Webrat.start_app_server
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "start_selenium_server" do
|
||||||
|
it "should not start the local selenium server if the selenium_server_address is set" do
|
||||||
|
Webrat.configuration.selenium_server_address = 'foo address'
|
||||||
|
::Selenium::RemoteControl::RemoteControl.should_not_receive(:new)
|
||||||
|
TCPSocket.should_receive(:wait_for_service).with(:host => Webrat.configuration.selenium_server_address, :port => Webrat.configuration.selenium_server_port)
|
||||||
|
Webrat.start_selenium_server
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should start the local selenium server if the selenium_server_address is set" do
|
||||||
|
remote_control = mock "selenium remote control"
|
||||||
|
::Selenium::RemoteControl::RemoteControl.should_receive(:new).with("0.0.0.0", Webrat.configuration.selenium_server_port, 5).and_return remote_control
|
||||||
|
remote_control.should_receive(:jar_file=).with(/selenium-server\.jar/)
|
||||||
|
remote_control.should_receive(:start).with(:background => true)
|
||||||
|
TCPSocket.should_receive(:wait_for_service).with(:host => "0.0.0.0", :port => Webrat.configuration.selenium_server_port)
|
||||||
|
Webrat.start_selenium_server
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "stop_selenium_server" do
|
||||||
|
|
||||||
|
it "should not attempt to stop the server if the selenium_server_address is set" do
|
||||||
|
Webrat.configuration.selenium_server_address = 'foo address'
|
||||||
|
::Selenium::RemoteControl::RemoteControl.should_not_receive(:new)
|
||||||
|
Webrat.stop_selenium_server
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should stop the local server is the selenium_server_address is nil" do
|
||||||
|
remote_control = mock "selenium remote control"
|
||||||
|
::Selenium::RemoteControl::RemoteControl.should_receive(:new).with("0.0.0.0", Webrat.configuration.selenium_server_port, 5).and_return remote_control
|
||||||
|
remote_control.should_receive(:stop)
|
||||||
|
Webrat.stop_selenium_server
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user