Skip to content

Commit e4bee71

Browse files
author
Sam Phippen
committed
Setup compatability with the rails-controller-testing gem.
This fixes a number of spec types, and requires the added setup lines. As a note, this is a soft, not hard dependency. We don't get automatic compatability. Instead, users will have to add the gem to their Gemfile if they want that functionality.
1 parent 7a13bf1 commit e4bee71

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

lib/rspec/rails/configuration.rb

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ class Configuration
3636
:feature => %w[spec features]
3737
}
3838

39+
# Sets up the different example group modules for the different spec types
40+
#
41+
# @api private
42+
def self.add_test_type_configurations(config)
43+
config.include RSpec::Rails::ControllerExampleGroup, :type => :controller
44+
config.include RSpec::Rails::HelperExampleGroup, :type => :helper
45+
config.include RSpec::Rails::ModelExampleGroup, :type => :model
46+
config.include RSpec::Rails::RequestExampleGroup, :type => :request
47+
config.include RSpec::Rails::RoutingExampleGroup, :type => :routing
48+
config.include RSpec::Rails::ViewExampleGroup, :type => :view
49+
config.include RSpec::Rails::FeatureExampleGroup, :type => :feature
50+
end
51+
3952
# @private
4053
def self.initialize_configuration(config)
4154
config.backtrace_exclusion_patterns << /vendor\//
@@ -98,13 +111,15 @@ def filter_rails_from_backtrace!
98111
end
99112
end
100113

101-
config.include RSpec::Rails::ControllerExampleGroup, :type => :controller
102-
config.include RSpec::Rails::HelperExampleGroup, :type => :helper
103-
config.include RSpec::Rails::ModelExampleGroup, :type => :model
104-
config.include RSpec::Rails::RequestExampleGroup, :type => :request
105-
config.include RSpec::Rails::RoutingExampleGroup, :type => :routing
106-
config.include RSpec::Rails::ViewExampleGroup, :type => :view
107-
config.include RSpec::Rails::FeatureExampleGroup, :type => :feature
114+
add_test_type_configurations(config)
115+
116+
if defined?(::Rails::Controller::Testing)
117+
[:controller, :view, :request].each do |type|
118+
config.include ::Rails::Controller::Testing::TestProcess, :type => type
119+
config.include ::Rails::Controller::Testing::TemplateAssertions, :type => type
120+
config.include ::Rails::Controller::Testing::Integration, :type => type
121+
end
122+
end
108123

109124
if defined?(ActionMailer)
110125
config.include RSpec::Rails::MailerExampleGroup, :type => :mailer

0 commit comments

Comments
 (0)