Skip to content

Commit 300943e

Browse files
authored
Merge pull request #1036 from rubocop-hq/use-the-new-multiple-terms-union-node-pattern-syntax
Use the new Node Pattern multiple term union syntax
2 parents f1f369d + 72a91ee commit 300943e

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

lib/rubocop/cop/rspec/around_block.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AroundBlock < Base
3131
'or `%<arg>s.run`.'
3232

3333
def_node_matcher :hook, <<-PATTERN
34-
(block {(send nil? :around) (send nil? :around sym)} (args $...) ...)
34+
(block (send nil? :around sym ?) (args $...) ...)
3535
PATTERN
3636

3737
def_node_search :find_arg_usage, <<-PATTERN

lib/rubocop/cop/rspec/implicit_block_expectation.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ class ImplicitBlockExpectation < Base
2222
def_node_matcher :lambda?, <<-PATTERN
2323
{
2424
(send (const nil? :Proc) :new)
25-
(send nil? :proc)
26-
(send nil? :lambda)
25+
(send nil? {:proc :lambda})
2726
}
2827
PATTERN
2928

lib/rubocop/cop/rspec/subject_stub.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ class SubjectStub < Base
4343
#
4444
# @yield [Symbol] subject name
4545
def_node_matcher :subject, <<-PATTERN
46-
{
47-
(block (send nil? :subject (sym $_)) args ...)
48-
(block (send nil? $:subject) args ...)
49-
}
46+
(block
47+
(send nil?
48+
{:subject (sym $_) | $:subject}
49+
) args ...)
5050
PATTERN
5151

5252
# @!method message_expectation?(node, method_name)

lib/rubocop/rspec/hook.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ module RSpec
66
class Hook < Concept
77
def_node_matcher :extract_metadata, <<~PATTERN
88
(block
9-
{
10-
(send _ _ #valid_scope? $...)
11-
(send _ _ $...)
12-
}
13-
...
9+
(send _ _ #valid_scope? ? $...) ...
1410
)
1511
PATTERN
1612

rubocop-rspec.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
3737
}
3838

3939
spec.add_runtime_dependency 'rubocop', '~> 0.87'
40+
spec.add_runtime_dependency 'rubocop-ast', '~> 0.7.1'
4041

4142
spec.add_development_dependency 'rack'
4243
spec.add_development_dependency 'rake'

0 commit comments

Comments
 (0)