Skip to content

Commit 8933275

Browse files
committed
fix(ruby): don't detect stray method calls as Rspec or Shoulda blocks
1 parent 8c89f27 commit 8933275

File tree

4 files changed

+145
-116
lines changed

4 files changed

+145
-116
lines changed

queries/ruby/aerial.scm

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,13 @@
5858
] @name
5959
(#set! "kind" "Module")) @symbol
6060

61-
; For Rspec, Rake, and Shoulda
61+
; For Rspec and Rake
6262
(call
6363
method: (identifier) @method @name
6464
(#any-of? @method
6565
"describe" "it" "before" "after" ; Rspec
66-
"namespace" "task" "multitask" "file" ; Rake
67-
"setup" "teardown" "should" "should_not" "should_eventually" "context")
68-
; Shoulda
66+
"namespace" "task" "multitask" "file"; Rake
67+
)
6968
arguments: (argument_list
7069
[
7170
(string
@@ -79,4 +78,32 @@
7978
])
8079
(call) @name
8180
])?
81+
block: (_)
82+
(#set! "kind" "Method")) @symbol @selection
83+
84+
; Rake and Shoulda
85+
(call
86+
method: (identifier) @method @name
87+
(#any-of? @method "setup" "teardown"; Shoulda
88+
)
89+
(#set! "kind" "Method")) @symbol @selection
90+
91+
(call
92+
method: (identifier) @method @name
93+
(#any-of? @method "task" ; Rake
94+
"should" "should_not" "should_eventually" "context"; Shoulda
95+
)
96+
arguments: (argument_list
97+
[
98+
(string
99+
(string_content) @name)
100+
(simple_symbol) @name
101+
(pair
102+
key: [
103+
(string
104+
(string_content) @name)
105+
(hash_key_symbol) @name
106+
])
107+
(call) @name
108+
]?)
82109
(#set! "kind" "Method")) @symbol @selection

0 commit comments

Comments
 (0)