Skip to content

Commit 1ec5c05

Browse files
committed
fixup! DSL aliases-inferred syntax changes
1 parent 8f9538d commit 1ec5c05

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

docs/modules/ROOT/pages/upgrade_to_version_2.adoc

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@ Example pull requests to replace `TopLevelDescribe` with `TopLevelGroup` [https:
146146

147147
=== Change the `Language` Module Usages
148148

149+
To allow for lazy initialization, and for loading of the language configuration after the class are loaded, a https://docs.rubocop.org/rubocop-ast/node_pattern.html#to-call-functions[function call feature of RuboCop AST] is used.
150+
149151
The `RuboCop::RSpec::Language` is completely different now.
152+
150153
`Hooks::ALL` and alike, and their accompanying helpers work differently.
151-
To allow for lazy initialization, and for loading of the language configuration after the class are loaded, a https://docs.rubocop.org/rubocop-ast/node_pattern.html#to-call-functions[function call feature of RuboCop AST] is used.
152154

153155
[source,ruby]
154156
----
@@ -158,7 +160,7 @@ def_node_matcher :shared_context,
158160
159161
# After
160162
def_node_matcher :shared_context,
161-
block_pattern('#rspec(:SharedGroups, :Context)')
163+
block_pattern('#SharedGroups.context')
162164
----
163165

164166
[source,ruby]
@@ -169,7 +171,7 @@ def_node_search :examples?,
169171
170172
# After
171173
def_node_search :examples?,
172-
send_pattern('{#rspec(:Includes, :Example) #rspec(:Examples)}')
174+
send_pattern('{#Includes.Example #Examples.all}')
173175
----
174176

175177
[source,ruby]
@@ -180,7 +182,36 @@ def_node_search :find_rspec_blocks,
180182
181183
# After
182184
def_node_search :find_rspec_blocks,
183-
block_pattern('#rspec(:ExampleGroups)')
185+
block_pattern('#ExampleGroups.all')
186+
----
187+
188+
If you were calling Language elements directly, you have to make the same adjustments:
189+
190+
[source,ruby]
191+
----
192+
# Before
193+
node&.sym_type? && Hooks::Scopes::ALL.include?(node.value)
194+
195+
# After
196+
node&.sym_type? && Language::HookScopes.all(node.value)
197+
----
198+
199+
You may see a common pattern in the change.
200+
There is a small exception, though:
201+
202+
[source,ruby]
203+
----
204+
# Before
205+
ExampleGroups::GROUPS
206+
207+
# After
208+
ExampleGroups#regular
209+
210+
# Before
211+
Examples::EXAMPLES
212+
213+
# After
214+
Examples#regular
184215
----
185216

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

0 commit comments

Comments
 (0)