Skip to content

Commit

Permalink
updating per reccomendations
Browse files Browse the repository at this point in the history
  • Loading branch information
gaffo committed Dec 9, 2008
1 parent 24ad539 commit ee86067
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 26 deletions.
10 changes: 1 addition & 9 deletions lib/webrat/core/configuration.rb
Expand Up @@ -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

Expand All @@ -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}")
Expand Down
4 changes: 2 additions & 2 deletions lib/webrat/core/elements/field.rb
Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions lib/webrat/core/logging.rb
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions lib/webrat/core/session.rb
Expand Up @@ -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}")
Expand Down
12 changes: 6 additions & 6 deletions spec/webrat/core/configuration_spec.rb
Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion spec/webrat/rails/helper.rb
Expand Up @@ -7,4 +7,4 @@
end

require "webrat/rails"
Webrat.configuration.mode_for_test = Webrat::Configuration::RAILS_MODE
Webrat.configuration.mode_for_test = :rails

0 comments on commit ee86067

Please sign in to comment.