Skip to content
Browse files

centralize the webrat config as well

  • Loading branch information...
1 parent 61b9fbb commit dbce7d25629d81c7a12e67dc87e4b34f14fbd05c @dchelimsky dchelimsky committed
View
2 gemfiles/base.rb
@@ -20,7 +20,7 @@ def self.extended(host)
gem "growl", "1.0.3"
gem "ZenTest", "~> 4.4.2"
- # gem "webrat", "0.7.2"
+ # gem "webrat", "0.7.3"
# gem "capybara", "~> 0.4"
# gem "capybara", "1.0.0.beta1"
View
32 lib/rspec/rails.rb
@@ -12,35 +12,5 @@
require 'rspec/rails/fixture_support'
require 'rspec/rails/mocks'
require 'rspec/rails/module_inclusion'
-require 'rspec/rails/browser_simulators'
require 'rspec/rails/example'
-
-begin
- require 'capybara/rspec'
-rescue LoadError
-end
-
-begin
- require 'capybara/rails'
-rescue LoadError
-end
-
-RSpec.configure do |c|
- if defined?(Capybara::RSpecMatchers)
- c.include Capybara::RSpecMatchers, :type => :view
- c.include Capybara::RSpecMatchers, :type => :helper
- c.include Capybara::RSpecMatchers, :type => :mailer
- c.include Capybara::RSpecMatchers, :type => :controller
- end
-
- if defined?(Capybara::DSL)
- c.include Capybara::DSL, :type => :controller
- end
-
- unless defined?(Capybara::RSpecMatchers) || defined?(Capybara::DSL)
- if defined?(Capybara)
- c.include Capybara, :type => :request
- c.include Capybara, :type => :controller
- end
- end
-end
+require 'rspec/rails/browser_simulators'
View
62 lib/rspec/rails/browser_simulators.rb
@@ -1,21 +1,61 @@
begin
+ require 'capybara/rspec'
+rescue LoadError
+end
+
+begin
+ require 'capybara/rails'
+rescue LoadError
+end
+
+begin
require 'webrat'
rescue LoadError
end
-module RSpec
- module Rails
- module BrowserSimulators
- extend ActiveSupport::Concern
-
- def self.included(mod)
- mod.instance_eval do
- def webrat(&block)
- block.call if defined?(Webrat)
- end
- end
+RSpec.configure do |c|
+ if defined?(Capybara::RSpecMatchers)
+ c.include Capybara::RSpecMatchers, :type => :view
+ c.include Capybara::RSpecMatchers, :type => :helper
+ c.include Capybara::RSpecMatchers, :type => :mailer
+ c.include Capybara::RSpecMatchers, :type => :controller
+ end
+
+ if defined?(Capybara::DSL)
+ c.include Capybara::DSL, :type => :controller
+ end
+
+ unless defined?(Capybara::RSpecMatchers) || defined?(Capybara::DSL)
+ if defined?(Capybara)
+ c.include Capybara, :type => :request
+ c.include Capybara, :type => :controller
+ end
+ end
+
+ if defined?(Webrat)
+ c.include Webrat::Matchers, :type => :request
+ c.include Webrat::Matchers, :type => :controller
+ c.include Webrat::Matchers, :type => :view
+ c.include Webrat::Matchers, :type => :helper
+ c.include Webrat::Matchers, :type => :mailer
+
+ c.include Webrat::Methods, :type => :request
+ c.include Webrat::Methods, :type => :controller
+
+ module RequestInstanceMethods
+ def last_response
+ @response
end
+ end
+
+ c.include RequestInstanceMethods, :type => :request
+
+ c.before :type => :controller do
+ Webrat.configure {|c| c.mode = :rails}
+ end
+ c.before :type => :request do
+ Webrat.configure {|c| c.mode = :rack}
end
end
end
View
12 lib/rspec/rails/example/controller_example_group.rb
@@ -82,12 +82,6 @@ module ControllerExampleGroup
include RSpec::Rails::Matchers::RedirectTo
include RSpec::Rails::Matchers::RenderTemplate
include RSpec::Rails::Matchers::RoutingMatchers
- include RSpec::Rails::BrowserSimulators
-
- webrat do
- include Webrat::Matchers
- include Webrat::Methods
- end
module ClassMethods
def controller_class
@@ -170,12 +164,6 @@ def method_missing(method, *args, &block)
@routes = ::Rails.application.routes
ActionController::Base.allow_forgery_protection = false
end
-
- webrat do
- before do
- Webrat.configure {|c| c.mode = :rails}
- end
- end
end
end
end
View
5 lib/rspec/rails/example/helper_example_group.rb
@@ -30,11 +30,6 @@ module HelperExampleGroup
include RSpec::Rails::RailsExampleGroup
include ActionView::TestCase::Behavior
include RSpec::Rails::ViewAssigns
- include RSpec::Rails::BrowserSimulators
-
- webrat do
- include Webrat::Matchers
- end
module ClassMethods
def determine_default_helper_class(ignore)
View
5 lib/rspec/rails/example/mailer_example_group.rb
@@ -4,11 +4,6 @@ module MailerExampleGroup
extend ActiveSupport::Concern
include RSpec::Rails::RailsExampleGroup
include ActionMailer::TestCase::Behavior
- include RSpec::Rails::BrowserSimulators
-
- webrat do
- include Webrat::Matchers
- end
included do
metadata[:type] = :mailer
View
21 lib/rspec/rails/example/request_example_group.rb
@@ -16,7 +16,6 @@ module RequestExampleGroup
include RSpec::Rails::RailsExampleGroup
include ActionDispatch::Integration::Runner
include ActionDispatch::Assertions
- include RSpec::Rails::BrowserSimulators
module InstanceMethods
def app
@@ -24,18 +23,6 @@ def app
end
end
- webrat do
- include Webrat::Matchers
- include Webrat::Methods
-
- module InstanceMethods
-
- def last_response
- @response
- end
- end
- end
-
include RSpec::Rails::Matchers::RedirectTo
include RSpec::Rails::Matchers::RenderTemplate
include ActionController::TemplateAssertions
@@ -46,14 +33,6 @@ def last_response
before do
@routes = ::Rails.application.routes
end
-
- webrat do
- before do
- Webrat.configure do |c|
- c.mode = :rack
- end
- end
- end
end
end
end
View
5 lib/rspec/rails/example/view_example_group.rb
@@ -23,11 +23,6 @@ module ViewExampleGroup
include ActionView::TestCase::Behavior
include RSpec::Rails::ViewAssigns
include RSpec::Rails::Matchers::RenderTemplate
- include RSpec::Rails::BrowserSimulators
-
- webrat do
- include Webrat::Matchers
- end
module ClassMethods
def _default_helper

0 comments on commit dbce7d2

Please sign in to comment.
Something went wrong with that request. Please try again.