Skip to content

Commit

Permalink
Webrat.configuration.application_type => Webrat.configuration.applica…
Browse files Browse the repository at this point in the history
…tion_framework
  • Loading branch information
atmos committed Feb 15, 2009
1 parent 7692930 commit 69dfa50
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/webrat/core/configuration.rb
Expand Up @@ -39,8 +39,8 @@ class Configuration
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 underlying app framework we're testing with selenium
attr_accessor :application_framework

# Which server the application is running on for selenium testing? Defaults to localhost
attr_accessor :application_address
Expand Down
8 changes: 3 additions & 5 deletions lib/webrat/selenium.rb
Expand Up @@ -34,24 +34,22 @@ def self.pid_file
end

def self.start_app_server #:nodoc:
case Webrat.configuration.application_type
case Webrat.configuration.application_framework
when :sinatra
fork do
File.open('rack.pid', 'w') { |fp| fp.write Process.pid }
exec 'rackup', File.expand_path(Dir.pwd + '/config.ru'), '-p', Webrat.configuration.application_port.to_s
end
when :merb
fork do
exec 'merb', '-d', '-p', Webrat.configuration.application_port
end
system("merb -d -p #{Webrat.configuration.application_port}"
else # rails
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
end

def self.stop_app_server #:nodoc:
case Webrat.configuration.application_type
case Webrat.configuration.application_framework
when :sinatra
pid = File.read('rack.pid')
system("kill -9 #{pid}")
Expand Down
12 changes: 6 additions & 6 deletions spec/private/selenium/selenium_spec.rb
Expand Up @@ -8,7 +8,7 @@

describe Webrat, "Selenium" do
describe "start_app_server" do
after(:each) { Webrat.configuration.application_type = :rails }
after(:each) { Webrat.configuration.application_framework = :rails }
describe "ruby on rails" do
it "should start the app server with correct config options" do
pid_file = "file"
Expand All @@ -20,7 +20,7 @@
end
describe "merb" do
it "should start the app server with correct config options" do
Webrat.configuration.application_type = :merb
Webrat.configuration.application_framework = :merb
Webrat.should_receive(:fork)
# Kernel.should_receive(:exec).with(['merb', '-d', '-p', Webrat.configuration.application_port])
TCPSocket.should_receive(:wait_for_service).with(:host => Webrat.configuration.application_address, :port => Webrat.configuration.application_port.to_i)
Expand All @@ -30,7 +30,7 @@
describe "sinatra" do
it "should start the app server with correct config options" do
rackup_file = File.expand_path(Dir.pwd + '/config.ru')
Webrat.configuration.application_type = :sinatra
Webrat.configuration.application_framework = :sinatra
Webrat.should_receive(:fork)
# Kernel.should_receive(:exec).with(['rackup', rackup_file, '-p', Webrat.configuration.application_port])
TCPSocket.should_receive(:wait_for_service).with(:host => Webrat.configuration.application_address, :port => Webrat.configuration.application_port.to_i)
Expand All @@ -40,7 +40,7 @@
end
end
describe "stop_app_server" do
after(:each) { Webrat.configuration.application_type = :rails }
after(:each) { Webrat.configuration.application_framework = :rails }
describe "ruby on rails" do
it "should stop the app server with correct config options" do
pid_file = RAILS_ROOT+'/tmp/pids/mongrel_selenium.pid'
Expand All @@ -50,15 +50,15 @@
end
describe "merb" do
it "should stop the app server with correct config options" do
Webrat.configuration.application_type = :merb
Webrat.configuration.application_framework = :merb
File.should_receive(:read).with('log/merb.3001.pid').and_return('666')
Webrat.should_receive(:system).with("kill -9 666")
Webrat.stop_app_server
end
end
describe "sinatra" do
it "should stop the app server with correct config options" do
Webrat.configuration.application_type = :sinatra
Webrat.configuration.application_framework = :sinatra
File.should_receive(:read).with('rack.pid').and_return('666')
Webrat.should_receive(:system).with("kill -9 666")
Webrat.stop_app_server
Expand Down

0 comments on commit 69dfa50

Please sign in to comment.