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)
|
||||
* 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
|
||||
* Expose #selenium method for direct access to Selenium client
|
||||
* 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:
|
||||
|
||||
require "webrat/rails"
|
||||
require "webrat"
|
||||
|
||||
Webrat.configure do |config|
|
||||
config.mode = :rails
|
||||
end
|
||||
|
||||
== Install with Merb
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ module Webrat
|
|||
# config.parse_with_nokogiri = false
|
||||
# end
|
||||
class Configuration
|
||||
|
||||
# Should XHTML be parsed with Nokogiri? Defaults to true, except on JRuby. When false, Hpricot and REXML are used
|
||||
attr_writer :parse_with_nokogiri
|
||||
|
||||
|
@ -39,6 +40,13 @@ module Webrat
|
|||
@open_error_files ? true : false
|
||||
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
|
|
@ -72,5 +72,3 @@ module Webrat #:nodoc:
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
Webrat.configuration.mode = :mechanize
|
|
@ -72,6 +72,3 @@ class Merb::Test::RspecStory #:nodoc:
|
|||
@browser ||= Webrat::MerbSession.new
|
||||
end
|
||||
end
|
||||
|
||||
Webrat.configuration.mode = :merb
|
||||
|
||||
|
|
|
@ -22,5 +22,3 @@ module Webrat
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
Webrat.configuration.mode = :rack
|
|
@ -86,11 +86,8 @@ module ActionController #:nodoc:
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
IntegrationTest.class_eval do
|
||||
include Webrat::Methods
|
||||
include Webrat::Matchers
|
||||
end
|
||||
end
|
||||
|
||||
Webrat.configuration.mode = :rails
|
|
@ -4,8 +4,6 @@ require "selenium/client"
|
|||
require "webrat/selenium/selenium_session"
|
||||
require "webrat/selenium/matchers"
|
||||
|
||||
Webrat.configuration.mode = :selenium
|
||||
|
||||
module Webrat
|
||||
|
||||
def self.with_selenium_server #:nodoc:
|
||||
|
|
|
@ -17,5 +17,3 @@ module Webrat
|
|||
|
||||
end
|
||||
end
|
||||
|
||||
Webrat.configuration.mode = :sinatra
|
|
@ -38,4 +38,10 @@ module Webrat
|
|||
def self.reset_for_test
|
||||
@@configuration = @@previous_config if @@previous_config
|
||||
end
|
||||
|
||||
class Configuration
|
||||
def mode_for_test= (mode)
|
||||
@mode = mode
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|||
describe Webrat::Configuration do
|
||||
predicate_matchers[:parse_with_nokogiri] = :parse_with_nokogiri?
|
||||
predicate_matchers[:open_error_files] = :open_error_files?
|
||||
|
||||
|
||||
before do
|
||||
Webrat.cache_config_for_test
|
||||
end
|
||||
|
@ -41,4 +41,17 @@ describe Webrat::Configuration do
|
|||
config = Webrat.configuration
|
||||
config.should_not open_error_files
|
||||
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
|
|
@ -3,13 +3,13 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|||
describe "Webrat::MechanizeSession" do
|
||||
before :all do
|
||||
Webrat.cache_config_for_test
|
||||
require "webrat/mechanize"
|
||||
Webrat.configuration.mode = :mechanize
|
||||
end
|
||||
|
||||
after :all do
|
||||
Webrat.reset_for_test
|
||||
end
|
||||
|
||||
|
||||
before(:each) do
|
||||
@mech = Webrat::MechanizeSession.new
|
||||
end
|
||||
|
|
|
@ -7,3 +7,4 @@ silence_warnings do
|
|||
end
|
||||
|
||||
require "webrat/rails"
|
||||
Webrat.configuration.mode_for_test = :rails
|
||||
|
|
Loading…
Reference in New Issue