Sets the Webrat mode with Configuration#mode= in the config block
This commit is contained in:
parent
6d7fc04f71
commit
22c7834512
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
* Maximize the browser window after initializing Selenium (Luke Melia)
|
* Maximize the browser window after initializing Selenium (Luke Melia)
|
||||||
* Better inspect output for Webrat elements
|
* Better inspect output for Webrat elements
|
||||||
|
* Sets the Webrat mode with Configuration#mode= in the config block [#85] (Mike Gaffney)
|
||||||
* Detect if the document is XML or HTML using the Content-Type when in Rails mode
|
* Detect if the document is XML or HTML using the Content-Type when in Rails mode
|
||||||
* Expose #selenium method for direct access to Selenium client
|
* Expose #selenium method for direct access to Selenium client
|
||||||
* Check nokogiri gem version before requiring nokogiri
|
* Check nokogiri gem version before requiring nokogiri
|
||||||
|
@ -61,7 +61,11 @@ To install the latest code as a plugin: (_Note:_ This may be less stable than us
|
|||||||
|
|
||||||
In your test_helper.rb, spec_helper.rb, or env.rb (for Cucumber) add:
|
In your test_helper.rb, spec_helper.rb, or env.rb (for Cucumber) add:
|
||||||
|
|
||||||
require "webrat/rails"
|
require "webrat"
|
||||||
|
|
||||||
|
Webrat.configure do |config|
|
||||||
|
config.mode = :rails
|
||||||
|
end
|
||||||
|
|
||||||
== Install with Merb
|
== Install with Merb
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ module Webrat
|
|||||||
# config.parse_with_nokogiri = false
|
# config.parse_with_nokogiri = false
|
||||||
# end
|
# end
|
||||||
class Configuration
|
class Configuration
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
@ -39,6 +40,13 @@ module Webrat
|
|||||||
@open_error_files ? true : false
|
@open_error_files ? true : false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Allows setting of webrat's mode, valid modes are:
|
||||||
|
# :rails, :selenium, :rack, :sinatra, :mechanize, :merb
|
||||||
|
def mode=(mode)
|
||||||
|
@mode = mode
|
||||||
|
require("webrat/#{mode}")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
@ -72,5 +72,3 @@ module Webrat #:nodoc:
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Webrat.configuration.mode = :mechanize
|
|
@ -72,6 +72,3 @@ class Merb::Test::RspecStory #:nodoc:
|
|||||||
@browser ||= Webrat::MerbSession.new
|
@browser ||= Webrat::MerbSession.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Webrat.configuration.mode = :merb
|
|
||||||
|
|
||||||
|
@ -22,5 +22,3 @@ module Webrat
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Webrat.configuration.mode = :rack
|
|
@ -86,11 +86,8 @@ module ActionController #:nodoc:
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
IntegrationTest.class_eval do
|
IntegrationTest.class_eval do
|
||||||
include Webrat::Methods
|
include Webrat::Methods
|
||||||
include Webrat::Matchers
|
include Webrat::Matchers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Webrat.configuration.mode = :rails
|
|
@ -4,8 +4,6 @@ require "selenium/client"
|
|||||||
require "webrat/selenium/selenium_session"
|
require "webrat/selenium/selenium_session"
|
||||||
require "webrat/selenium/matchers"
|
require "webrat/selenium/matchers"
|
||||||
|
|
||||||
Webrat.configuration.mode = :selenium
|
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
|
|
||||||
def self.with_selenium_server #:nodoc:
|
def self.with_selenium_server #:nodoc:
|
||||||
|
@ -17,5 +17,3 @@ module Webrat
|
|||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Webrat.configuration.mode = :sinatra
|
|
@ -38,4 +38,10 @@ module Webrat
|
|||||||
def self.reset_for_test
|
def self.reset_for_test
|
||||||
@@configuration = @@previous_config if @@previous_config
|
@@configuration = @@previous_config if @@previous_config
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Configuration
|
||||||
|
def mode_for_test= (mode)
|
||||||
|
@mode = mode
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
@ -41,4 +41,17 @@ describe Webrat::Configuration do
|
|||||||
config = Webrat.configuration
|
config = Webrat.configuration
|
||||||
config.should_not open_error_files
|
config.should_not open_error_files
|
||||||
end
|
end
|
||||||
|
|
||||||
|
[: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}")
|
||||||
|
config.mode = mode
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|||||||
describe "Webrat::MechanizeSession" do
|
describe "Webrat::MechanizeSession" do
|
||||||
before :all do
|
before :all do
|
||||||
Webrat.cache_config_for_test
|
Webrat.cache_config_for_test
|
||||||
require "webrat/mechanize"
|
Webrat.configuration.mode = :mechanize
|
||||||
end
|
end
|
||||||
|
|
||||||
after :all do
|
after :all do
|
||||||
|
@ -7,3 +7,4 @@ silence_warnings do
|
|||||||
end
|
end
|
||||||
|
|
||||||
require "webrat/rails"
|
require "webrat/rails"
|
||||||
|
Webrat.configuration.mode_for_test = :rails
|
||||||
|
Loading…
Reference in New Issue
Block a user