updating per reccomendations
This commit is contained in:
parent
24ad539671
commit
ee86067829
@ -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}")
|
||||
|
@ -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 }
|
||||
|
@ -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
|
||||
|
@ -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}")
|
||||
|
@ -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}")
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user