small fixup for sinatra + selenium, use rackup instead of mongrel_rails if config.ru exists
This commit is contained in:
parent
24eab77ecd
commit
82eabc31ee
@ -25,16 +25,32 @@ module Webrat
|
|||||||
::Selenium::RemoteControl::RemoteControl.new("0.0.0.0", Webrat.configuration.selenium_server_port, 5).stop unless Webrat.configuration.selenium_server_address
|
::Selenium::RemoteControl::RemoteControl.new("0.0.0.0", Webrat.configuration.selenium_server_port, 5).stop unless Webrat.configuration.selenium_server_address
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.pid_file
|
||||||
|
if File.exists?('config.ru')
|
||||||
|
prepare_pid_file(Dir.pwd, 'rack.pid')
|
||||||
|
else
|
||||||
|
prepare_pid_file("#{RAILS_ROOT}/tmp/pids", "mongrel_selenium.pid")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.start_app_server #:nodoc:
|
def self.start_app_server #:nodoc:
|
||||||
pid_file = prepare_pid_file("#{RAILS_ROOT}/tmp/pids", "mongrel_selenium.pid")
|
if File.exists?('config.ru')
|
||||||
|
fork do
|
||||||
|
exec 'rackup', File.expand_path(Dir.pwd + '/config.ru'), '-P', 'rack.pid'
|
||||||
|
end
|
||||||
|
else
|
||||||
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} &")
|
||||||
|
end
|
||||||
TCPSocket.wait_for_service :host => Webrat.configuration.application_address, :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:
|
||||||
pid_file = File.expand_path(RAILS_ROOT + "/tmp/pids/mongrel_selenium.pid")
|
if File.exists?('config.ru')
|
||||||
|
system("kill -9 `cat rack.pid`")
|
||||||
|
else
|
||||||
system "mongrel_rails stop -c #{RAILS_ROOT} --pid #{pid_file}"
|
system "mongrel_rails stop -c #{RAILS_ROOT} --pid #{pid_file}"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.prepare_pid_file(file_path, pid_file_name)
|
def self.prepare_pid_file(file_path, pid_file_name)
|
||||||
FileUtils.mkdir_p File.expand_path(file_path)
|
FileUtils.mkdir_p File.expand_path(file_path)
|
||||||
@ -90,10 +106,10 @@ module Webrat
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module ActionController #:nodoc:
|
#module ActionController #:nodoc:
|
||||||
IntegrationTest.class_eval do
|
# IntegrationTest.class_eval do
|
||||||
include Webrat::Methods
|
# include Webrat::Methods
|
||||||
include Webrat::Selenium::Methods
|
# include Webrat::Selenium::Methods
|
||||||
include Webrat::Selenium::Matchers
|
# include Webrat::Selenium::Matchers
|
||||||
end
|
# end
|
||||||
end
|
#end
|
||||||
|
@ -179,12 +179,22 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
def silence_stream(stream)
|
||||||
|
old_stream = stream.dup
|
||||||
|
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
||||||
|
stream.sync = true
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
stream.reopen(old_stream)
|
||||||
|
end
|
||||||
|
|
||||||
def setup #:nodoc:
|
def setup #:nodoc:
|
||||||
silence_stream(STDOUT) do
|
silence_stream(STDOUT) do
|
||||||
|
silence_stream(STDERR) do
|
||||||
Webrat.start_selenium_server
|
Webrat.start_selenium_server
|
||||||
Webrat.start_app_server
|
Webrat.start_app_server
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
create_browser
|
create_browser
|
||||||
$browser.start
|
$browser.start
|
||||||
|
Loading…
Reference in New Issue
Block a user