diff --git a/lib/webrat/core/configuration.rb b/lib/webrat/core/configuration.rb index d6ae615f..5344d9fd 100755 --- a/lib/webrat/core/configuration.rb +++ b/lib/webrat/core/configuration.rb @@ -18,13 +18,6 @@ def self.configuration # :nodoc: # end class Configuration - RAILS_MODE = :rails - SELENIUM_MODE = :selenium - RACK_MODE = :rack - SINATRA_MODE = :sinatra - MECHANIZE_MODE = :mechanize - MERB_MODE = :merb - # Should XHTML be parsed with Nokogiri? Defaults to true, except on JRuby. When false, Hpricot and REXML are used attr_writer :parse_with_nokogiri @@ -48,8 +41,7 @@ def open_error_files? #:nodoc: end # Allows setting of webrat's mode, valid modes are: - # RAILS_MODE - Used in typical rails development - # SELENIUM_MODE - Used for webrat in selenium mode + # :rails, :selenium, :rack, :sinatra, :mechanize, :merb def mode=(mode) @mode = mode require("webrat/#{mode}") diff --git a/lib/webrat/core/elements/field.rb b/lib/webrat/core/elements/field.rb index fd359c0e..8f16ba34 100644 --- a/lib/webrat/core/elements/field.rb +++ b/lib/webrat/core/elements/field.rb @@ -78,9 +78,9 @@ def to_param return nil if disabled? case Webrat.configuration.mode - when Webrat::Configuration::RAILS_MODE + when :rails ActionController::AbstractRequest.parse_query_parameters("#{name}=#{escaped_value}") - when Webrat::Configuration::MERB_MODE + when :merb ::Merb::Parse.query("#{name}=#{escaped_value}") else { name => escaped_value } diff --git a/lib/webrat/core/logging.rb b/lib/webrat/core/logging.rb index 6e791ab7..817548e2 100644 --- a/lib/webrat/core/logging.rb +++ b/lib/webrat/core/logging.rb @@ -8,9 +8,9 @@ def debug_log(message) # :nodoc: def logger # :nodoc: case Webrat.configuration.mode - when Webrat::Configuration::RAILS_MODE + when :rails defined?(RAILS_DEFAULT_LOGGER) ? RAILS_DEFAULT_LOGGER : nil - when Webrat::Configuration::MERB_MODE + when :merb Merb.logger else nil diff --git a/lib/webrat/core/session.rb b/lib/webrat/core/session.rb index ae038a84..0ca3ffa1 100644 --- a/lib/webrat/core/session.rb +++ b/lib/webrat/core/session.rb @@ -10,17 +10,17 @@ class PageLoadError < WebratError def self.session_class case Webrat.configuration.mode - when Webrat::Configuration::RAILS_MODE + when :rails RailsSession - when Webrat::Configuration::MERB_MODE + when :merb MerbSession - when Webrat::Configuration::SELENIUM_MODE + when :selenium SeleniumSession - when Webrat::Configuration::RACK_MODE + when :rack RackSession - when Webrat::Configuration::SINATRA_MODE + when :sinatra SinatraSession - when Webrat::Configuration::MECHANIZE_MODE + when :mechanize MechanizeSession else raise WebratError.new("Unknown Webrat mode: #{Webrat.configuration.mode.inspect}") diff --git a/spec/webrat/core/configuration_spec.rb b/spec/webrat/core/configuration_spec.rb index 70f34d1c..b03f499a 100755 --- a/spec/webrat/core/configuration_spec.rb +++ b/spec/webrat/core/configuration_spec.rb @@ -42,12 +42,12 @@ config.should_not open_error_files end - [Webrat::Configuration::RAILS_MODE, - Webrat::Configuration::SELENIUM_MODE, - Webrat::Configuration::RACK_MODE, - Webrat::Configuration::SINATRA_MODE, - Webrat::Configuration::MERB_MODE, - Webrat::Configuration::MECHANIZE_MODE].each do |mode| + [:rails, + :selenium, + :rack, + :sinatra, + :merb, + :mechanize].each do |mode| it "should require correct lib when in #{mode} mode" do config = Webrat::Configuration.new config.should_receive(:require).with("webrat/#{mode}") diff --git a/spec/webrat/rails/helper.rb b/spec/webrat/rails/helper.rb index 9704a41b..14d5790c 100644 --- a/spec/webrat/rails/helper.rb +++ b/spec/webrat/rails/helper.rb @@ -7,4 +7,4 @@ end require "webrat/rails" -Webrat.configuration.mode_for_test = Webrat::Configuration::RAILS_MODE +Webrat.configuration.mode_for_test = :rails