cleanup and tests closes LH #82
This commit is contained in:
parent
813adcc238
commit
8c0facc5af
|
@ -26,8 +26,7 @@ module Webrat
|
|||
end
|
||||
|
||||
def self.start_app_server #:nodoc:
|
||||
FileUtils.mkdir_p File.expand_path(RAILS_ROOT + "/tmp/pids")
|
||||
pid_file = File.expand_path(RAILS_ROOT + "/tmp/pids/mongrel_selenium.pid")
|
||||
pid_file = prepare_pid_file("#{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} &")
|
||||
TCPSocket.wait_for_service :host => Webrat.configuration.application_address, :port => Webrat.configuration.application_port.to_i
|
||||
end
|
||||
|
@ -37,6 +36,11 @@ module Webrat
|
|||
system "mongrel_rails stop -c #{RAILS_ROOT} --pid #{pid_file}"
|
||||
end
|
||||
|
||||
def self.prepare_pid_file(file_path, pid_file_name)
|
||||
FileUtils.mkdir_p File.expand_path(file_path)
|
||||
File.expand_path("#{file_path}/#{pid_file_name}")
|
||||
end
|
||||
|
||||
# To use Webrat's Selenium support, you'll need the selenium-client gem installed.
|
||||
# Activate it with (for example, in your <tt>env.rb</tt>):
|
||||
#
|
||||
|
|
|
@ -10,12 +10,19 @@ describe Webrat, "Selenium" do
|
|||
|
||||
it "should start the app server with correct config options" do
|
||||
pid_file = "file"
|
||||
File.should_receive(:expand_path).with(RAILS_ROOT + "/tmp/pids/mongrel_selenium.pid").and_return pid_file
|
||||
Webrat.should_receive(:prepare_pid_file).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} &")
|
||||
TCPSocket.should_receive(:wait_for_service).with(:host => Webrat.configuration.application_address, :port => Webrat.configuration.application_port.to_i)
|
||||
Webrat.start_app_server
|
||||
end
|
||||
|
||||
it 'prepare_pid_file' do
|
||||
File.should_receive(:expand_path).with('path').and_return('full_path')
|
||||
FileUtils.should_receive(:mkdir_p).with 'full_path'
|
||||
File.should_receive(:expand_path).with('path/name')
|
||||
Webrat.prepare_pid_file 'path', 'name'
|
||||
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'
|
||||
|
|
Loading…
Reference in New Issue