allow picking your appserver type via a configuration option, not discovering framework specific files in the current working directory. also start rack apps with the application port parameter
This commit is contained in:
parent
8fbcbef180
commit
4bf49a5163
@ -39,6 +39,9 @@ module Webrat
|
|||||||
webrat_deprecate :selenium_port, :application_port
|
webrat_deprecate :selenium_port, :application_port
|
||||||
webrat_deprecate :selenium_port=, :application_port=
|
webrat_deprecate :selenium_port=, :application_port=
|
||||||
|
|
||||||
|
# Which underlying appserver are we testing with selenium
|
||||||
|
attr_accessor :application_type
|
||||||
|
|
||||||
# Which server the application is running on for selenium testing? Defaults to localhost
|
# Which server the application is running on for selenium testing? Defaults to localhost
|
||||||
attr_accessor :application_address
|
attr_accessor :application_address
|
||||||
|
|
||||||
@ -61,6 +64,7 @@ module Webrat
|
|||||||
self.application_environment = :selenium
|
self.application_environment = :selenium
|
||||||
self.application_port = 3001
|
self.application_port = 3001
|
||||||
self.application_address = 'localhost'
|
self.application_address = 'localhost'
|
||||||
|
self.application_type = 'rails'
|
||||||
self.selenium_server_port = 4444
|
self.selenium_server_port = 4444
|
||||||
self.infinite_redirect_limit = 10
|
self.infinite_redirect_limit = 10
|
||||||
self.selenium_browser_key = '*firefox'
|
self.selenium_browser_key = '*firefox'
|
||||||
|
@ -34,23 +34,33 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.start_app_server #:nodoc:
|
def self.start_app_server #:nodoc:
|
||||||
if File.exists?('config.ru')
|
case Webrat.configuration.application_type
|
||||||
|
when :sinatra
|
||||||
fork do
|
fork do
|
||||||
File.open('rack.pid', 'w') { |fp| fp.write Process.pid }
|
File.open('rack.pid', 'w') { |fp| fp.write Process.pid }
|
||||||
exec 'rackup', File.expand_path(Dir.pwd + '/config.ru')
|
exec 'rackup', File.expand_path(Dir.pwd + '/config.ru'), '-p', Webrat.configuration.application_port.to_s
|
||||||
end
|
end
|
||||||
else
|
when :merb
|
||||||
|
fork do
|
||||||
|
exec 'merb', '-d'
|
||||||
|
end
|
||||||
|
else # rails
|
||||||
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
|
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:
|
||||||
if File.exists?('config.ru')
|
case Webrat.configuration.application_type
|
||||||
|
when :sinatra
|
||||||
pid = File.read('rack.pid')
|
pid = File.read('rack.pid')
|
||||||
system("kill -9 #{pid}")
|
system("kill -9 #{pid}")
|
||||||
FileUtils.rm_f 'rack.pid'
|
FileUtils.rm_f 'rack.pid'
|
||||||
else
|
when :merb
|
||||||
|
pid = File.read('log/merb.4000.pid')
|
||||||
|
system("kill -9 #{pid}")
|
||||||
|
FileUtils.rm_f 'log/merb.4000.pid'
|
||||||
|
else # rails
|
||||||
system "mongrel_rails stop -c #{RAILS_ROOT} --pid #{pid_file}"
|
system "mongrel_rails stop -c #{RAILS_ROOT} --pid #{pid_file}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user