Skip to content

Commit fa78d97

Browse files
committed
fixup! Add a note about calling super
1 parent 1ec5c05 commit fa78d97

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/modules/ROOT/pages/upgrade_to_version_2.adoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ In version 2.x:
99
- `CustomIncludeMethods` configuration option for `RSpec/EmptyExampleGroup` is removed
1010
- cop departments are nested for cops with a department that doesn’t match the extension name (`Capybara`, `FactoryBot`, `Rails`)
1111
- `AllCops/RSpec/Patterns`/`AllCops/FactoryBot/Patterns` options are removed
12+
- Calling `super` from `on_new_investigation` defined in a cop is mandatory now
1213

1314
[discrete]
1415
=== Adjust the configuration of `RSpec/EmptyExampleGroup`
@@ -216,6 +217,30 @@ Examples#regular
216217

217218
https://github.com/rubocop-hq/rubocop-rspec/pull/956[Pull request with more examples].
218219

220+
=== Always call `super` from `on_new_investigation` in your cops
221+
222+
`on_new_investigation` is now used for internal purposes, and not calling `super` from your cop involves a risk of configuration not being properly loaded, and dynamic RSpec DSL matchers won't work.
223+
224+
NOTE: You don't have to define `on_new_investigation` in your cops unless you need to.
225+
226+
[source,ruby]
227+
----
228+
module RuboCop
229+
module Cop
230+
module RSpec
231+
class MultipleMemoizedHelpers < Base
232+
def on_new_investigation
233+
super # Always call `super`
234+
@example_group_memoized_helpers = {}
235+
end
236+
end
237+
end
238+
end
239+
end
240+
----
241+
242+
https://github.com/rubocop-hq/rubocop-rspec/pull/956[Pull request with more examples].
243+
219244
=== Conform with RuboCop API Changes
220245

221246
The parent project, RuboCop, has API changes.

0 commit comments

Comments
 (0)