@@ -117,10 +117,7 @@ def handle_describe(node)
117
117
118
118
#: (Prism::CallNode) -> void
119
119
def handle_example ( node )
120
- # Minitest formats the descriptions into test method names by using the count of examples with the description
121
- # We are not guaranteed to discover examples in the exact order using static analysis, so we use the line number
122
- # instead. Note that anonymous examples mixed with meta-programming will not be handled correctly
123
- description = extract_description ( node ) || "anonymous"
120
+ description = extract_it_description ( node )
124
121
line = node . location . start_line - 1
125
122
parent = latest_group
126
123
return unless parent . is_a? ( Requests ::Support ::TestItem )
@@ -141,16 +138,37 @@ def handle_example(node)
141
138
142
139
#: (Prism::CallNode) -> String?
143
140
def extract_description ( node )
141
+ arguments = node . arguments &.arguments
142
+ return unless arguments
143
+
144
+ parts = arguments . map { |arg | extract_argument_content ( arg ) }
145
+ return if parts . empty?
146
+
147
+ parts . join ( "::" )
148
+ end
149
+
150
+ #: (Prism::CallNode) -> String
151
+ def extract_it_description ( node )
152
+ # Minitest formats the descriptions into test method names by using the count of examples with the description
153
+ # We are not guaranteed to discover examples in the exact order using static analysis, so we use the line number
154
+ # instead. Note that anonymous examples mixed with meta-programming will not be handled correctly
144
155
first_argument = node . arguments &.arguments &.first
145
- return unless first_argument
156
+ return "anonymous" unless first_argument
157
+
158
+ extract_argument_content ( first_argument ) || "anonymous"
159
+ end
146
160
147
- case first_argument
161
+ #: (Prism::Node) -> String?
162
+ def extract_argument_content ( arg )
163
+ case arg
148
164
when Prism ::StringNode
149
- first_argument . content
165
+ arg . content
166
+ when Prism ::SymbolNode
167
+ arg . value
150
168
when Prism ::ConstantReadNode , Prism ::ConstantPathNode
151
- constant_name ( first_argument )
169
+ constant_name ( arg )
152
170
else
153
- first_argument . slice
171
+ arg . slice
154
172
end
155
173
end
156
174
0 commit comments