@@ -45,15 +45,40 @@ class Configuration
4545 #
4646 # @api private
4747 def self . add_test_type_configurations ( config )
48- config . include RSpec ::Rails ::ControllerExampleGroup , type : :controller
49- config . include RSpec ::Rails ::HelperExampleGroup , type : :helper
50- config . include RSpec ::Rails ::ModelExampleGroup , type : :model
51- config . include RSpec ::Rails ::RequestExampleGroup , type : :request
52- config . include RSpec ::Rails ::RoutingExampleGroup , type : :routing
53- config . include RSpec ::Rails ::ViewExampleGroup , type : :view
54- config . include RSpec ::Rails ::FeatureExampleGroup , type : :feature
48+ config . define_derived_metadata ( type : :controller ) do
49+ config . include RSpec ::Rails ::ControllerExampleGroup , type : :controller
50+ end
51+
52+ config . define_derived_metadata ( type : :helper ) do
53+ config . include RSpec ::Rails ::HelperExampleGroup , type : :helper
54+ end
55+
56+ config . define_derived_metadata ( type : :model ) do
57+ config . include RSpec ::Rails ::ModelExampleGroup , type : :model
58+ end
59+
60+ config . define_derived_metadata ( type : :request ) do
61+ config . include RSpec ::Rails ::RequestExampleGroup , type : :request
62+ end
63+
64+ config . define_derived_metadata ( type : :routing ) do
65+ require "action_controller/test_case"
66+ config . include RSpec ::Rails ::RoutingExampleGroup , type : :routing
67+ end
68+
69+ config . define_derived_metadata ( type : :view ) do
70+ config . include RSpec ::Rails ::ViewExampleGroup , type : :view
71+ end
72+
73+ config . define_derived_metadata ( type : :feature ) do
74+ config . include RSpec ::Rails ::FeatureExampleGroup , type : :feature
75+ end
76+
5577 config . include RSpec ::Rails ::Matchers
56- config . include RSpec ::Rails ::SystemExampleGroup , type : :system
78+
79+ config . define_derived_metadata ( type : :system ) do
80+ config . include RSpec ::Rails ::SystemExampleGroup , type : :system
81+ end
5782 end
5883
5984 # @private
@@ -192,27 +217,38 @@ def fixture_path=(path)
192217
193218 if defined? ( ::Rails ::Controller ::Testing )
194219 [ :controller , :view , :request ] . each do |type |
195- config . include ::Rails ::Controller ::Testing ::TestProcess , type : type
196- config . include ::Rails ::Controller ::Testing ::TemplateAssertions , type : type
197- config . include ::Rails ::Controller ::Testing ::Integration , type : type
220+ config . define_derived_metadata ( type : type ) do
221+ config . include ::Rails ::Controller ::Testing ::TestProcess , type : type
222+ config . include ::Rails ::Controller ::Testing ::TemplateAssertions , type : type
223+ config . include ::Rails ::Controller ::Testing ::Integration , type : type
224+ end
198225 end
199226 end
200227
201228 if RSpec ::Rails ::FeatureCheck . has_action_mailer?
202- config . include RSpec ::Rails ::MailerExampleGroup , type : :mailer
229+ config . define_derived_metadata ( type : :mailer ) do
230+ config . include RSpec ::Rails ::MailerExampleGroup , type : :mailer
231+ end
232+
203233 config . after { ActionMailer ::Base . deliveries . clear }
204234 end
205235
206236 if RSpec ::Rails ::FeatureCheck . has_active_job?
207- config . include RSpec ::Rails ::JobExampleGroup , type : :job
237+ config . define_derived_metadata ( type : :job ) do
238+ config . include RSpec ::Rails ::JobExampleGroup , type : :job
239+ end
208240 end
209241
210242 if RSpec ::Rails ::FeatureCheck . has_action_cable_testing?
211- config . include RSpec ::Rails ::ChannelExampleGroup , type : :channel
243+ config . define_derived_metadata ( type : :channel ) do
244+ config . include RSpec ::Rails ::ChannelExampleGroup , type : :channel
245+ end
212246 end
213247
214248 if RSpec ::Rails ::FeatureCheck . has_action_mailbox?
215- config . include RSpec ::Rails ::MailboxExampleGroup , type : :mailbox
249+ config . define_derived_metadata ( type : :mailbox ) do
250+ config . include RSpec ::Rails ::MailboxExampleGroup , type : :mailbox
251+ end
216252 end
217253 end
218254
0 commit comments