2008-11-16 23:58:24 +00:00
|
|
|
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
|
|
|
|
|
|
describe Webrat::Configuration do
|
2009-08-20 02:43:23 +00:00
|
|
|
|
2009-06-15 03:37:35 +00:00
|
|
|
Spec::Matchers.define :open_error_files do
|
|
|
|
match do |config|
|
|
|
|
config.open_error_files?
|
|
|
|
end
|
|
|
|
end
|
2009-08-20 02:43:23 +00:00
|
|
|
|
2008-11-23 19:44:13 +00:00
|
|
|
it "should have a mode" do
|
|
|
|
Webrat.configuration.should respond_to(:mode)
|
|
|
|
end
|
2009-01-12 18:13:22 +00:00
|
|
|
|
2008-11-23 04:49:12 +00:00
|
|
|
it "should open error files by default" do
|
2008-11-23 19:49:05 +00:00
|
|
|
config = Webrat::Configuration.new
|
2008-11-23 19:59:07 +00:00
|
|
|
config.should open_error_files
|
2008-11-16 23:58:24 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2009-02-09 01:54:00 +00:00
|
|
|
it "should detect infinite redirects after 10" do
|
|
|
|
config = Webrat::Configuration.new
|
|
|
|
config.infinite_redirect_limit.should == 10
|
|
|
|
end
|
2009-01-12 18:13:22 +00:00
|
|
|
|
2008-11-16 23:58:24 +00:00
|
|
|
it "should be configurable with a block" do
|
|
|
|
Webrat.configure do |config|
|
|
|
|
config.open_error_files = false
|
|
|
|
end
|
2009-01-12 18:13:22 +00:00
|
|
|
|
2008-11-16 23:58:24 +00:00
|
|
|
config = Webrat.configuration
|
2008-11-23 19:59:07 +00:00
|
|
|
config.should_not open_error_files
|
2008-11-16 23:58:24 +00:00
|
|
|
end
|
2009-01-12 18:13:22 +00:00
|
|
|
|
2009-01-18 21:15:56 +00:00
|
|
|
it "should be configurable with multiple blocks" do
|
|
|
|
Webrat.configure do |config|
|
|
|
|
config.open_error_files = false
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2009-01-18 21:15:56 +00:00
|
|
|
Webrat.configure do |config|
|
|
|
|
config.selenium_server_port = 1234
|
|
|
|
end
|
|
|
|
|
|
|
|
config = Webrat.configuration
|
|
|
|
config.should_not open_error_files
|
|
|
|
config.selenium_server_port.should == 1234
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2009-01-12 18:13:22 +00:00
|
|
|
[:rails,
|
2009-01-12 18:50:53 +00:00
|
|
|
:selenium,
|
|
|
|
:rack,
|
|
|
|
:sinatra,
|
|
|
|
:mechanize].each do |mode|
|
2008-12-26 04:04:41 +00:00
|
|
|
it "should require correct lib when in #{mode} mode" do
|
|
|
|
config = Webrat::Configuration.new
|
|
|
|
config.should_receive(:require).with("webrat/#{mode}")
|
|
|
|
config.mode = mode
|
|
|
|
end
|
|
|
|
end
|
2009-01-12 18:13:22 +00:00
|
|
|
|
2009-08-13 00:50:55 +00:00
|
|
|
it "should require merb_adapter when in merb mode" do
|
2009-01-18 21:20:58 +00:00
|
|
|
config = Webrat::Configuration.new
|
2009-08-13 00:50:55 +00:00
|
|
|
config.should_receive(:require).with("webrat/merb_adapter")
|
2009-01-18 21:20:58 +00:00
|
|
|
config.mode = :merb
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2009-01-12 18:50:53 +00:00
|
|
|
describe "Selenium" do
|
|
|
|
before :each do
|
|
|
|
@config = Webrat::Configuration.new
|
|
|
|
end
|
|
|
|
|
2009-04-06 18:00:14 +00:00
|
|
|
it "should use 'test' as the application environment by default" do
|
|
|
|
@config.application_environment.should == :test
|
2009-01-12 18:50:53 +00:00
|
|
|
end
|
2009-01-12 18:13:22 +00:00
|
|
|
|
2009-01-12 18:50:53 +00:00
|
|
|
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
|
2009-01-12 21:15:11 +00:00
|
|
|
|
|
|
|
it 'should default selenium browser key to *firefox' do
|
|
|
|
@config.selenium_browser_key.should == '*firefox'
|
|
|
|
end
|
2009-06-04 17:18:31 +00:00
|
|
|
|
2009-05-18 21:37:45 +00:00
|
|
|
it 'should default selenium browser startup timeout to 5 seconds' do
|
|
|
|
@config.selenium_browser_startup_timeout.should == 5
|
|
|
|
end
|
2009-06-04 17:18:31 +00:00
|
|
|
|
2009-05-18 21:37:45 +00:00
|
|
|
it 'should allow overriding of the browser startup timeout' do
|
|
|
|
@config.selenium_browser_startup_timeout = 10
|
|
|
|
@config.selenium_browser_startup_timeout.should == 10
|
|
|
|
end
|
2009-01-12 18:50:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|