updating per reccomendations
This commit is contained in:
parent
24ad539671
commit
ee86067829
@ -18,13 +18,6 @@ module Webrat
|
|||||||
# end
|
# end
|
||||||
class Configuration
|
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
|
# Should XHTML be parsed with Nokogiri? Defaults to true, except on JRuby. When false, Hpricot and REXML are used
|
||||||
attr_writer :parse_with_nokogiri
|
attr_writer :parse_with_nokogiri
|
||||||
|
|
||||||
@ -48,8 +41,7 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Allows setting of webrat's mode, valid modes are:
|
# Allows setting of webrat's mode, valid modes are:
|
||||||
# RAILS_MODE - Used in typical rails development
|
# :rails, :selenium, :rack, :sinatra, :mechanize, :merb
|
||||||
# SELENIUM_MODE - Used for webrat in selenium mode
|
|
||||||
def mode=(mode)
|
def mode=(mode)
|
||||||
@mode = mode
|
@mode = mode
|
||||||
require("webrat/#{mode}")
|
require("webrat/#{mode}")
|
||||||
|
@ -78,9 +78,9 @@ module Webrat
|
|||||||
return nil if disabled?
|
return nil if disabled?
|
||||||
|
|
||||||
case Webrat.configuration.mode
|
case Webrat.configuration.mode
|
||||||
when Webrat::Configuration::RAILS_MODE
|
when :rails
|
||||||
ActionController::AbstractRequest.parse_query_parameters("#{name}=#{escaped_value}")
|
ActionController::AbstractRequest.parse_query_parameters("#{name}=#{escaped_value}")
|
||||||
when Webrat::Configuration::MERB_MODE
|
when :merb
|
||||||
::Merb::Parse.query("#{name}=#{escaped_value}")
|
::Merb::Parse.query("#{name}=#{escaped_value}")
|
||||||
else
|
else
|
||||||
{ name => escaped_value }
|
{ name => escaped_value }
|
||||||
|
@ -8,9 +8,9 @@ module Webrat
|
|||||||
|
|
||||||
def logger # :nodoc:
|
def logger # :nodoc:
|
||||||
case Webrat.configuration.mode
|
case Webrat.configuration.mode
|
||||||
when Webrat::Configuration::RAILS_MODE
|
when :rails
|
||||||
defined?(RAILS_DEFAULT_LOGGER) ? RAILS_DEFAULT_LOGGER : nil
|
defined?(RAILS_DEFAULT_LOGGER) ? RAILS_DEFAULT_LOGGER : nil
|
||||||
when Webrat::Configuration::MERB_MODE
|
when :merb
|
||||||
Merb.logger
|
Merb.logger
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
|
@ -10,17 +10,17 @@ module Webrat
|
|||||||
|
|
||||||
def self.session_class
|
def self.session_class
|
||||||
case Webrat.configuration.mode
|
case Webrat.configuration.mode
|
||||||
when Webrat::Configuration::RAILS_MODE
|
when :rails
|
||||||
RailsSession
|
RailsSession
|
||||||
when Webrat::Configuration::MERB_MODE
|
when :merb
|
||||||
MerbSession
|
MerbSession
|
||||||
when Webrat::Configuration::SELENIUM_MODE
|
when :selenium
|
||||||
SeleniumSession
|
SeleniumSession
|
||||||
when Webrat::Configuration::RACK_MODE
|
when :rack
|
||||||
RackSession
|
RackSession
|
||||||
when Webrat::Configuration::SINATRA_MODE
|
when :sinatra
|
||||||
SinatraSession
|
SinatraSession
|
||||||
when Webrat::Configuration::MECHANIZE_MODE
|
when :mechanize
|
||||||
MechanizeSession
|
MechanizeSession
|
||||||
else
|
else
|
||||||
raise WebratError.new("Unknown Webrat mode: #{Webrat.configuration.mode.inspect}")
|
raise WebratError.new("Unknown Webrat mode: #{Webrat.configuration.mode.inspect}")
|
||||||
|
@ -42,12 +42,12 @@ describe Webrat::Configuration do
|
|||||||
config.should_not open_error_files
|
config.should_not open_error_files
|
||||||
end
|
end
|
||||||
|
|
||||||
[Webrat::Configuration::RAILS_MODE,
|
[:rails,
|
||||||
Webrat::Configuration::SELENIUM_MODE,
|
:selenium,
|
||||||
Webrat::Configuration::RACK_MODE,
|
:rack,
|
||||||
Webrat::Configuration::SINATRA_MODE,
|
:sinatra,
|
||||||
Webrat::Configuration::MERB_MODE,
|
:merb,
|
||||||
Webrat::Configuration::MECHANIZE_MODE].each do |mode|
|
:mechanize].each do |mode|
|
||||||
it "should require correct lib when in #{mode} mode" do
|
it "should require correct lib when in #{mode} mode" do
|
||||||
config = Webrat::Configuration.new
|
config = Webrat::Configuration.new
|
||||||
config.should_receive(:require).with("webrat/#{mode}")
|
config.should_receive(:require).with("webrat/#{mode}")
|
||||||
|
@ -7,4 +7,4 @@ silence_warnings do
|
|||||||
end
|
end
|
||||||
|
|
||||||
require "webrat/rails"
|
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