diff --git a/lib/webrat/core/configuration.rb b/lib/webrat/core/configuration.rb index d6ae615..5344d9f 100755 --- a/lib/webrat/core/configuration.rb +++ b/lib/webrat/core/configuration.rb @@ -18,13 +18,6 @@ module Webrat # 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 @@ module Webrat 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 fd359c0..8f16ba3 100644 --- a/lib/webrat/core/elements/field.rb +++ b/lib/webrat/core/elements/field.rb @@ -78,9 +78,9 @@ module Webrat 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 6e791ab..817548e 100644 --- a/lib/webrat/core/logging.rb +++ b/lib/webrat/core/logging.rb @@ -8,9 +8,9 @@ module Webrat 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 ae038a8..0ca3ffa 100644 --- a/lib/webrat/core/session.rb +++ b/lib/webrat/core/session.rb @@ -10,17 +10,17 @@ module Webrat 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 70f34d1..b03f499 100755 --- a/spec/webrat/core/configuration_spec.rb +++ b/spec/webrat/core/configuration_spec.rb @@ -42,12 +42,12 @@ describe Webrat::Configuration do 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 9704a41..14d5790 100644 --- a/spec/webrat/rails/helper.rb +++ b/spec/webrat/rails/helper.rb @@ -7,4 +7,4 @@ silence_warnings do end require "webrat/rails" -Webrat.configuration.mode_for_test = Webrat::Configuration::RAILS_MODE +Webrat.configuration.mode_for_test = :rails