Save and open page storage directory now defaults to "tmp" under current directory if exists, otherwise current directory

This commit is contained in:
Noah Davis 2010-01-17 18:29:35 -05:00
parent d50d24e09e
commit ccaf41160c
2 changed files with 5 additions and 7 deletions

View File

@ -1,4 +1,5 @@
require "webrat/core_extensions/deprecate" require "webrat/core_extensions/deprecate"
require "pathname"
module Webrat module Webrat
@ -26,7 +27,7 @@ module Webrat
# Save and open pages with error status codes (500-599) in a browser? Defualts to true. # Save and open pages with error status codes (500-599) in a browser? Defualts to true.
attr_writer :open_error_files attr_writer :open_error_files
# Save and open page storage directory, defaults to current directory # Save and open page storage directory, defaults to "tmp" under current directory if exists, otherwise current directory
attr_accessor :saved_pages_dir attr_accessor :saved_pages_dir
# Which rails environment should the selenium tests be run in? Defaults to test. # Which rails environment should the selenium tests be run in? Defaults to test.
@ -63,7 +64,6 @@ module Webrat
def initialize # :nodoc: def initialize # :nodoc:
self.open_error_files = true self.open_error_files = true
self.saved_pages_dir = File.expand_path(".")
self.application_environment = :test self.application_environment = :test
self.application_port = 3001 self.application_port = 3001
self.application_address = 'localhost' self.application_address = 'localhost'
@ -72,6 +72,9 @@ module Webrat
self.infinite_redirect_limit = 10 self.infinite_redirect_limit = 10
self.selenium_browser_key = '*firefox' self.selenium_browser_key = '*firefox'
self.selenium_browser_startup_timeout = 5 self.selenium_browser_startup_timeout = 5
tmp_dir = Pathname.new(Dir.pwd).join("tmp")
self.saved_pages_dir = tmp_dir.exist? ? tmp_dir : Dir.pwd
end end
def open_error_files? #:nodoc: def open_error_files? #:nodoc:

View File

@ -17,11 +17,6 @@ describe Webrat::Configuration do
config.should open_error_files config.should open_error_files
end end
it "should default saved_pages_dir to current dir" do
config = Webrat::Configuration.new
config.saved_pages_dir.should == File.expand_path(".")
end
it "should detect infinite redirects after 10" do it "should detect infinite redirects after 10" do
config = Webrat::Configuration.new config = Webrat::Configuration.new
config.infinite_redirect_limit.should == 10 config.infinite_redirect_limit.should == 10