added selenium_server port and address and application address for configuring selenium more dynamically

This commit is contained in:
cornel.borcean 2009-01-12 12:50:53 -06:00
parent 0ce92dfcd8
commit 0edffe0ac4
2 changed files with 42 additions and 16 deletions

View File

@ -37,11 +37,22 @@ module Webrat
attr_accessor :application_port attr_accessor :application_port
webrat_deprecate :selenium_port, :application_port webrat_deprecate :selenium_port, :application_port
# Which server the application is running on for selenium testing? Defaults to localhost
attr_accessor :application_address
# Which server Selenium server is running on. Defaults to nil(server starts in webrat process and runs locally)
attr_accessor :selenium_server_address
# Which server Selenium port is running on. Defaults to 4444
attr_accessor :selenium_server_port
def initialize # :nodoc: def initialize # :nodoc:
self.open_error_files = true self.open_error_files = true
self.parse_with_nokogiri = !Webrat.on_java? self.parse_with_nokogiri = !Webrat.on_java?
self.application_environment = :selenium self.application_environment = :selenium
self.application_port = 3001 self.application_port = 3001
self.application_address = "localhost"
self.selenium_server_port = 4444
end end
def parse_with_nokogiri? #:nodoc: def parse_with_nokogiri? #:nodoc:

View File

@ -25,16 +25,6 @@ describe Webrat::Configuration do
config.should open_error_files config.should open_error_files
end end
it "should use 'selenium' as the application environment by default" do
config = Webrat::Configuration.new
config.application_environment.should == :selenium
end
it "should use 3001 as the application port by default" do
config = Webrat::Configuration.new
config.application_port.should == 3001
end
it "should be configurable with a block" do it "should be configurable with a block" do
Webrat.configure do |config| Webrat.configure do |config|
config.open_error_files = false config.open_error_files = false
@ -45,11 +35,11 @@ describe Webrat::Configuration do
end end
[:rails, [:rails,
:selenium, :selenium,
:rack, :rack,
:sinatra, :sinatra,
:merb, :merb,
:mechanize].each do |mode| :mechanize].each do |mode|
it "should require correct lib when in #{mode} mode" do it "should require correct lib when in #{mode} mode" do
config = Webrat::Configuration.new config = Webrat::Configuration.new
config.should_receive(:require).with("webrat/#{mode}") config.should_receive(:require).with("webrat/#{mode}")
@ -57,5 +47,30 @@ describe Webrat::Configuration do
end end
end end
end describe "Selenium" do
before :each do
@config = Webrat::Configuration.new
end
it "should use 'selenium' as the application environment by default" do
@config.application_environment.should == :selenium
end
it "should use 3001 as the application port by default" do
@config.application_port.should == 3001
end
it 'should default application address to localhost' do
@config.application_address.should == 'localhost'
end
it 'should default selenium server address to nil' do
@config.selenium_server_address.should be_nil
end
it 'should default selenium server port to 4444' do
@config.selenium_server_port.should == 4444
end
end
end