@@ -194,8 +194,8 @@ class Foo::User < ApplicationRecord
194
194
FILE
195
195
end
196
196
let ( :expected_comments ) { [ ] }
197
- let ( :expected_starts ) { [ [ "FactoryBot" , 0 ] , [ "factory" , 1 ] , [ "admin" , 2 ] , [ "factory" , 3 ] , [ " FactoryBot", 4 ] ] }
198
- let ( :expected_ends ) { [ [ "admin" , 2 ] , [ "end" , 3 ] , [ "end" , 4 ] ] }
197
+ let ( :expected_starts ) { [ [ "FactoryBot" , 0 ] , [ "factory" , 1 ] , [ "admin" , 2 ] , [ "FactoryBot" , 4 ] ] }
198
+ let ( :expected_ends ) { [ [ "admin" , 2 ] , [ "end" , 3 ] , [ "factory" , 3 ] , [ " end", 4 ] ] }
199
199
200
200
it "parses correctly" do
201
201
check_it_parses_correctly
@@ -214,9 +214,9 @@ class Foo::User < ApplicationRecord
214
214
end
215
215
let ( :expected_comments ) { [ ] }
216
216
let ( :expected_starts ) {
217
- [ [ "factory" , 0 ] , [ "first_name" , 1 ] , [ "last_name" , 2 ] , [ "date_of_birth" , 3 ] , [ "factory" , 4 ] ]
217
+ [ [ "factory" , 0 ] , [ "first_name" , 1 ] , [ "last_name" , 2 ] , [ "date_of_birth" , 3 ] ]
218
218
}
219
- let ( :expected_ends ) { [ [ "first_name" , 1 ] , [ "last_name" , 2 ] , [ "date_of_birth" , 3 ] , [ "end" , 4 ] ] }
219
+ let ( :expected_ends ) { [ [ "first_name" , 1 ] , [ "last_name" , 2 ] , [ "date_of_birth" , 3 ] , [ "end" , 4 ] , [ "factory" , 4 ] ] }
220
220
221
221
it "parses correctly" do
222
222
check_it_parses_correctly
@@ -235,8 +235,44 @@ class Foo::User < ApplicationRecord
235
235
FILE
236
236
end
237
237
let ( :expected_comments ) { [ [ "# typed: strong" , 0 ] ] }
238
- let ( :expected_starts ) { [ [ "factory" , 1 ] , [ "first_name" , 2 ] , [ "last_name" , 3 ] , [ "date_of_birth" , 4 ] , [ "factory" , 5 ] ] }
239
- let ( :expected_ends ) { [ [ "first_name" , 2 ] , [ "last_name" , 3 ] , [ "date_of_birth" , 4 ] , [ "end" , 5 ] ] }
238
+ let ( :expected_starts ) { [ [ "factory" , 1 ] , [ "first_name" , 2 ] , [ "last_name" , 3 ] , [ "date_of_birth" , 4 ] ] }
239
+ let ( :expected_ends ) { [ [ "first_name" , 2 ] , [ "last_name" , 3 ] , [ "date_of_birth" , 4 ] , [ "end" , 5 ] , [ "factory" , 5 ] ] }
240
+
241
+ it "parses correctly" do
242
+ check_it_parses_correctly
243
+ end
244
+ end
245
+
246
+ context "when using an RSpec file" do
247
+ let ( :input ) do
248
+ <<~FILE
249
+ RSpec.describe "Collapsed::TestModel" do
250
+ # Deliberately left empty
251
+ end
252
+ FILE
253
+ end
254
+ let ( :expected_comments ) { [ [ "# Deliberately left empty" , 1 ] ] }
255
+ let ( :expected_starts ) { [ [ "RSpec" , 0 ] ] }
256
+ let ( :expected_ends ) { [ [ "end" , 2 ] , [ "RSpec" , 2 ] ] }
257
+
258
+ it "parses correctly" do
259
+ check_it_parses_correctly
260
+ end
261
+ end
262
+
263
+ context "when using an RSpec file with monkeypatching" do
264
+ # Should be removed by RSpec 4+
265
+ # https://github.com/rspec/rspec-core/issues/2301
266
+ let ( :input ) do
267
+ <<~FILE
268
+ describe "Collapsed::TestModel" do
269
+ # Deliberately left empty
270
+ end
271
+ FILE
272
+ end
273
+ let ( :expected_comments ) { [ [ "# Deliberately left empty" , 1 ] ] }
274
+ let ( :expected_starts ) { [ [ "describe" , 0 ] ] }
275
+ let ( :expected_ends ) { [ [ "end" , 2 ] , [ "describe" , 2 ] ] }
240
276
241
277
it "parses correctly" do
242
278
check_it_parses_correctly
0 commit comments