test_launcher 2.20.0 → 2.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/test_launcher/frameworks/minitest.rb +7 -2
  3. data/lib/test_launcher/search/git.rb +2 -1
  4. data/lib/test_launcher/version.rb +1 -1
  5. data/test_launcher.gemspec +1 -1
  6. metadata +3 -60
  7. data/.gitignore +0 -16
  8. data/Gemfile +0 -8
  9. data/README.md +0 -419
  10. data/Rakefile +0 -9
  11. data/test/install +0 -3
  12. data/test/test_helper.rb +0 -65
  13. data/test/test_helpers/integration_helper.rb +0 -33
  14. data/test/test_helpers/mock.rb +0 -59
  15. data/test/test_helpers/mock_searcher.rb +0 -1
  16. data/test/test_helpers/mocks.rb +0 -77
  17. data/test/test_helpers/mocks/searcher_mock.rb +0 -84
  18. data/test/test_launcher/cli/input_parser_test.rb +0 -79
  19. data/test/test_launcher/ex_unit_integration_test.rb +0 -413
  20. data/test/test_launcher/frameworks/implementation/test_case_test.rb +0 -73
  21. data/test/test_launcher/frameworks/minitest/runner_test.rb +0 -76
  22. data/test/test_launcher/frameworks/minitest/searcher_test.rb +0 -109
  23. data/test/test_launcher/frameworks/rspec/runner_test.rb +0 -83
  24. data/test/test_launcher/frameworks/rspec/searcher_test.rb +0 -54
  25. data/test/test_launcher/generic_integration_test.rb +0 -62
  26. data/test/test_launcher/minitest_integration_test.rb +0 -683
  27. data/test/test_launcher/queries/example_name_query_test.rb +0 -221
  28. data/test/test_launcher/queries/full_regex_query_test.rb +0 -153
  29. data/test/test_launcher/queries/generic_query_test.rb +0 -23
  30. data/test/test_launcher/queries/line_number_query_test.rb +0 -107
  31. data/test/test_launcher/queries/multi_path_query_test.rb +0 -126
  32. data/test/test_launcher/queries/path_query_test.rb +0 -192
  33. data/test/test_launcher/rspec_integration_test.rb +0 -574
  34. data/test/test_launcher/rubymine_test.rb +0 -65
  35. data/test/test_launcher/search/ag_test.rb +0 -42
  36. data/test/test_launcher/search/git_test.rb +0 -41
@@ -1,683 +0,0 @@
1
- require "test_helper"
2
- require "test_helpers/integration_helper"
3
-
4
- module TestLauncher
5
- class MinitestIntegrationTest < TestCase
6
- include IntegrationHelper
7
-
8
- def launch(query, env: {}, searcher:, shell: shell_mock)
9
- query += " --framework minitest "
10
- shell.reset
11
- CLI.launch(query.split(" "), env, shell: shell, searcher: searcher)
12
- end
13
-
14
- def test__by_example__single_method
15
- searcher = MemorySearcher.new do |searcher|
16
- searcher.mock_file do |f|
17
- f.path "/src/test/class_1_test.rb"
18
- f.contents <<-RB
19
- class Class1Test
20
- def test_name
21
- end
22
- end
23
- RB
24
- end
25
- end
26
-
27
- launch("test_name", searcher: searcher)
28
- assert_equal "cd /src && bundle exec ruby -I test /src/test/class_1_test.rb --name='/test_name/'", shell_mock.recall_exec
29
-
30
- launch("n", searcher: searcher)
31
- assert_equal "cd /src && bundle exec ruby -I test /src/test/class_1_test.rb --name='/n/'", shell_mock.recall_exec
32
- end
33
-
34
- def test__by_example__multiple_methods__same_file
35
- searcher = MemorySearcher.new do |searcher|
36
- searcher.mock_file do |f|
37
- f.path "/src/test/class_1_test.rb"
38
- f.contents <<-RB
39
- class Class1Test
40
- def test_name_1
41
- end
42
-
43
- def test_name_2
44
- end
45
- end
46
- RB
47
- end
48
- end
49
-
50
- launch("name_", searcher: searcher)
51
- assert_equal "cd /src && bundle exec ruby -I test /src/test/class_1_test.rb --name='/name_/'", shell_mock.recall_exec
52
- end
53
-
54
- def test__by_example__multiple_methods__regex_issue
55
- searcher = MemorySearcher.new do |searcher|
56
- searcher.mock_file do |f|
57
- f.path "/src/test/class_1_test.rb"
58
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
59
- f.contents <<-RB
60
- def test_name_1
61
- RB
62
- end
63
-
64
- searcher.mock_file do |f|
65
- f.path "/src/test/class_2_test.rb"
66
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
67
- f.contents <<-RB
68
- def test_somename
69
- RB
70
- end
71
- end
72
-
73
- launch("test_name", searcher: searcher)
74
- assert_equal "cd /src && bundle exec ruby -I test /src/test/class_1_test.rb --name='/test_name/'", shell_mock.recall_exec
75
-
76
- skip
77
- # not seeing a good solution here...
78
- # we cannot tell whether the _ is part of the test_ or not.
79
- # might need to do two passes: first with user input, then
80
- # filter down to those that match test_...would that work?
81
- launch("_name", searcher: searcher)
82
- assert_equal "cd /src && bundle exec ruby -I test /src/test/class_1_test.rb --name='/test_name/'", shell_mock.recall_exec
83
- end
84
-
85
- def test__by_example__multiple_methods__different_files
86
- searcher = MemorySearcher.new do |searcher|
87
- searcher.mock_file do |f|
88
- f.path "/src/test/class_1_test.rb"
89
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
90
- f.contents <<-RB
91
- def test_name_1
92
- def test_name_2
93
- RB
94
- end
95
-
96
- searcher.mock_file do |f|
97
- f.path "/src/test/class_2_test.rb"
98
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
99
- f.contents <<-RB
100
- def test_name_1
101
- def test_name_2
102
- RB
103
- end
104
-
105
- searcher.mock_file do |f|
106
- f.path "/src/test/class_3_test.rb"
107
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
108
- f.contents <<-RB
109
- def test_name_2
110
- RB
111
- end
112
- end
113
-
114
- launch("name_1", searcher: searcher)
115
- assert_equal "cd /src && bundle exec ruby -I test /src/test/class_2_test.rb --name='/name_1/'", shell_mock.recall_exec
116
-
117
- launch("name_2", searcher: searcher)
118
- assert_equal "cd /src && bundle exec ruby -I test /src/test/class_2_test.rb --name='/name_2/'", shell_mock.recall_exec
119
-
120
- launch("name_1 --all", searcher: searcher)
121
- assert_equal "cd /src && bundle exec ruby -I test -r bundler/setup -e \"ARGV.push('--name=/name_1/')\" -r /src/test/class_1_test.rb -r /src/test/class_2_test.rb", shell_mock.recall_exec
122
-
123
- launch("name_2 --all", searcher: searcher)
124
- assert_equal "cd /src && bundle exec ruby -I test -r bundler/setup -e \"ARGV.push('--name=/name_2/')\" -r /src/test/class_1_test.rb -r /src/test/class_2_test.rb -r /src/test/class_3_test.rb", shell_mock.recall_exec
125
-
126
- launch("name_1|name_2 --all", searcher: searcher)
127
- assert_equal "cd /src && bundle exec ruby -I test -r bundler/setup -e \"ARGV.push('--name=/name_1|name_2/')\" -r /src/test/class_1_test.rb -r /src/test/class_2_test.rb -r /src/test/class_3_test.rb", shell_mock.recall_exec
128
- end
129
-
130
- def test__by_filename
131
- searcher = MemorySearcher.new do |searcher|
132
- searcher.mock_file do |f|
133
- f.path "/src/test/file_1_test.rb"
134
- f.contents ""
135
- end
136
- end
137
-
138
- launch("file_1", searcher: searcher)
139
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
140
-
141
- launch("file_1_test.rb", searcher: searcher)
142
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
143
-
144
- launch("/file_1", searcher: searcher)
145
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
146
-
147
- launch(".rb", searcher: searcher)
148
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
149
-
150
- launch("/src/test/file_1", searcher: searcher)
151
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
152
-
153
- launch("src/test/file_1", searcher: searcher)
154
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
155
-
156
- launch("st/file_1", searcher: searcher)
157
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
158
- end
159
-
160
- def test__by_filename__multiple_files_found
161
- searcher = MemorySearcher.new do |searcher|
162
- searcher.mock_file do |f|
163
- f.path "/src/test/file_1_test.rb"
164
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
165
- end
166
-
167
- searcher.mock_file do |f|
168
- f.path "/src/test/file_2_test.rb"
169
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
170
- end
171
-
172
- searcher.mock_file do |f|
173
- f.path "/src/test/file_3_test.rb"
174
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
175
- end
176
-
177
- searcher.mock_file do |f|
178
- f.path "/src/test/other_test.rb"
179
- end
180
- end
181
-
182
- launch("file_1", searcher: searcher)
183
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
184
-
185
- launch("file", searcher: searcher)
186
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_2_test.rb", shell_mock.recall_exec
187
-
188
- launch("file --all", searcher: searcher)
189
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb /src/test/file_2_test.rb /src/test/file_3_test.rb", shell_mock.recall_exec
190
- end
191
-
192
- def test__by_filename__preferred_over_regex_and_test_name_matches
193
- searcher = MemorySearcher.new do |searcher|
194
- searcher.mock_file do |f|
195
- f.path "/src/test/class_1_test.rb"
196
- f.contents <<-RB
197
- def test_name
198
- RB
199
- end
200
-
201
- searcher.mock_file do |f|
202
- f.path "/src/test/name_test.rb"
203
- end
204
-
205
- searcher.mock_file do |f|
206
- f.path "/src/test/other_test.rb"
207
- f.contents <<-RB
208
- regex will match name_test
209
- RB
210
- end
211
- end
212
-
213
- launch("name_test", searcher: searcher)
214
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/name_test.rb", shell_mock.recall_exec
215
- end
216
-
217
- def test__by_multiple_filenames__multiple_files_found
218
- searcher = MemorySearcher.new do |searcher|
219
- searcher.mock_file do |f|
220
- f.path "/src/test/file_1_test.rb"
221
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
222
- f.contents ""
223
- end
224
-
225
- searcher.mock_file do |f|
226
- f.path "/src/test/file_2_test.rb"
227
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
228
- f.contents ""
229
- end
230
-
231
- searcher.mock_file do |f|
232
- f.path "/src/test/file_3_test.rb"
233
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
234
- f.contents ""
235
- end
236
-
237
- searcher.mock_file do |f|
238
- f.path "/src/test/other_test.rb"
239
- f.contents ""
240
- end
241
- end
242
-
243
- launch("file_1 file_2", searcher: searcher)
244
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb /src/test/file_2_test.rb", shell_mock.recall_exec
245
-
246
- launch("file_1 file", searcher: searcher)
247
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb /src/test/file_2_test.rb /src/test/file_3_test.rb", shell_mock.recall_exec
248
-
249
- # If multiple queries are submitted but not all of them match,
250
- # then what should we do? For now, we assume that it's only
251
- # considered a match if each query term matches at least one
252
- # or more files.
253
- launch("file_1 gibberish", searcher: searcher)
254
- assert_equal nil, shell_mock.recall_exec
255
- end
256
-
257
- def test_uses_spring__if_spring_binstub_found
258
- searcher = MemorySearcher.new do |searcher|
259
- searcher.mock_file do |f|
260
- f.path "/src/test/class_1_test.rb"
261
- f.contents <<-RB
262
- def test_name
263
- RB
264
- end
265
-
266
- searcher.mock_file do |f|
267
- f.path "/src/bin/spring"
268
- f.contents ""
269
- end
270
- end
271
-
272
- launch("class_1_test.rb", env: {}, searcher: searcher)
273
- assert_equal "cd /src && bundle exec spring rails test test/class_1_test.rb", shell_mock.recall_exec
274
-
275
- launch("class_1_test.rb", env: {"DISABLE_SPRING" => "1"}, searcher: searcher)
276
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/class_1_test.rb", shell_mock.recall_exec
277
-
278
- launch("class_1_test.rb --disable-spring", searcher: searcher)
279
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/class_1_test.rb", shell_mock.recall_exec
280
- end
281
-
282
- def test_uses_spring__if_forced
283
- searcher = MemorySearcher.new do |searcher|
284
- searcher.mock_file do |f|
285
- f.path "/src/test/class_1_test.rb"
286
- f.contents <<-RB
287
- def test_name
288
- RB
289
- end
290
- end
291
-
292
- launch("class_1_test.rb --spring", env: {}, searcher: searcher)
293
- assert_equal "cd /src && bundle exec spring rails test test/class_1_test.rb", shell_mock.recall_exec
294
- end
295
-
296
- def test__by_regex__one_match
297
- searcher = MemorySearcher.new do |searcher|
298
- searcher.mock_file do |f|
299
- f.path "/src/test/file_1_test.rb"
300
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
301
- f.contents <<-RB
302
- regex match 1
303
- regex match 2
304
- regex match 3
305
- RB
306
- end
307
-
308
- searcher.mock_file do |f|
309
- f.path "/src/test/file_2_test.rb"
310
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
311
- f.contents <<-RB
312
- regex match 1
313
- regex match 2
314
- RB
315
- end
316
-
317
- searcher.mock_file do |f|
318
- f.path "/src/test/file_3_test.rb"
319
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
320
- f.contents <<-RB
321
- regex match 1
322
- regex match 3
323
- RB
324
- end
325
- end
326
-
327
- launch("regex match 1", searcher: searcher)
328
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_2_test.rb", shell_mock.recall_exec
329
-
330
- launch("regex match 3", searcher: searcher)
331
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_3_test.rb", shell_mock.recall_exec
332
-
333
- launch("regex match", searcher: searcher)
334
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_2_test.rb", shell_mock.recall_exec
335
-
336
- launch("regex match --all", searcher: searcher)
337
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb /src/test/file_2_test.rb /src/test/file_3_test.rb", shell_mock.recall_exec
338
- end
339
-
340
- def test__by_example__preferred_over_regex
341
- searcher = MemorySearcher.new do |searcher|
342
- searcher.mock_file do |f|
343
- f.path "/src/test/file_1_test.rb"
344
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
345
- f.contents <<-RB
346
- def test_regex_match
347
- RB
348
- end
349
-
350
- searcher.mock_file do |f|
351
- f.path "/src/test/file_2_test.rb"
352
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
353
- f.contents <<-RB
354
- regex_match
355
- RB
356
- end
357
- end
358
-
359
- launch("regex_match", searcher: searcher)
360
- assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name='/regex_match/'", shell_mock.recall_exec
361
- end
362
-
363
- def test__multiple_queries__generic_regex__prefers_to_keep_spaces
364
- searcher = MemorySearcher.new do |searcher|
365
- searcher.mock_file do |f|
366
- f.path "/src/test/file_1_test.rb"
367
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
368
- f.contents <<-RB
369
- this matches
370
- RB
371
- end
372
-
373
- searcher.mock_file do |f|
374
- f.path "/src/test/file_2_test.rb"
375
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
376
- f.contents <<-RB
377
- this
378
- matches
379
- RB
380
- end
381
-
382
- launch("this matches", searcher: searcher)
383
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
384
-
385
- launch("this matches --all", searcher: searcher)
386
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
387
-
388
- launch("matches this --all", searcher: searcher)
389
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb /src/test/file_2_test.rb", shell_mock.recall_exec
390
- end
391
- end
392
-
393
- def test__multiple_queries__splits_spaces_for_test_names
394
- searcher = MemorySearcher.new do |searcher|
395
- searcher.mock_file do |f|
396
- f.path "/src/test/file_1_test.rb"
397
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
398
- f.contents <<-RB
399
- def test_this
400
- RB
401
- end
402
-
403
- searcher.mock_file do |f|
404
- f.path "/src/test/file_2_test.rb"
405
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
406
- f.contents <<-RB
407
- def test_matches
408
- RB
409
- end
410
-
411
- launch("this matches", searcher: searcher)
412
- assert_equal "cd /src && bundle exec ruby -I test -r bundler/setup -e \"ARGV.push('--name=/this|matches/')\" -r /src/test/file_1_test.rb -r /src/test/file_2_test.rb", shell_mock.recall_exec
413
-
414
- launch("this matches --all", searcher: searcher)
415
- assert_equal "cd /src && bundle exec ruby -I test -r bundler/setup -e \"ARGV.push('--name=/this|matches/')\" -r /src/test/file_1_test.rb -r /src/test/file_2_test.rb", shell_mock.recall_exec
416
-
417
- launch("this matches", searcher: searcher)
418
- assert_equal "cd /src && bundle exec ruby -I test -r bundler/setup -e \"ARGV.push('--name=/this|matches/')\" -r /src/test/file_1_test.rb -r /src/test/file_2_test.rb", shell_mock.recall_exec
419
- end
420
- end
421
-
422
- def test__helper_methods_are_considered_regexes
423
- searcher = MemorySearcher.new do |searcher|
424
- searcher.mock_file do |f|
425
- f.path "/src/test/file_1_test.rb"
426
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
427
- f.contents <<-RB
428
- def helper_method
429
- RB
430
- end
431
- end
432
-
433
- launch("helper_method", searcher: searcher)
434
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
435
- end
436
-
437
- def test__by_example__handles_regex_for_example_name
438
- searcher = MemorySearcher.new do |searcher|
439
- searcher.mock_file do |f|
440
- f.path "/src/test/file_1_test.rb"
441
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
442
- f.contents <<-RB
443
- def test_name_1
444
- RB
445
- end
446
-
447
- searcher.mock_file do |f|
448
- f.path "/src/test/file_2_test.rb"
449
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
450
- f.contents <<-RB
451
- def test_name_2
452
- RB
453
- end
454
- end
455
-
456
- launch("test_name_1$", searcher: searcher)
457
- assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name='/test_name_1$/'", shell_mock.recall_exec
458
-
459
- launch("test_name_2|test_name_1", searcher: searcher)
460
- assert_equal "cd /src && bundle exec ruby -I test /src/test/file_2_test.rb --name='/test_name_2|test_name_1/'", shell_mock.recall_exec
461
-
462
- launch('test_name_\d', searcher: searcher)
463
- assert_equal "cd /src && bundle exec ruby -I test /src/test/file_2_test.rb --name='/test_name_\\d/'", shell_mock.recall_exec
464
-
465
- launch('test_name_\d --all', searcher: searcher)
466
- assert_equal %{cd /src && bundle exec ruby -I test -r bundler/setup -e "ARGV.push('--name=/test_name_\\d/')" -r /src/test/file_1_test.rb -r /src/test/file_2_test.rb}, shell_mock.recall_exec
467
- end
468
-
469
- def test__not_found
470
- searcher = MemorySearcher.new do |searcher|
471
- searcher.mock_file do |f|
472
- f.path "/src/test/file_1_test.rb"
473
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
474
- f.contents <<-RB
475
- some stuff
476
- RB
477
- end
478
- end
479
-
480
- launch("gibberish", searcher: searcher)
481
- assert_equal nil, shell_mock.recall_exec
482
- end
483
-
484
- def test__different_roots
485
- searcher = MemorySearcher.new do |searcher|
486
- searcher.mock_file do |f|
487
- f.path "/src/test/file_1_test.rb"
488
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
489
- f.contents <<-RB
490
- def test_name_1
491
- RB
492
- end
493
-
494
- searcher.mock_file do |f|
495
- f.path "/src/test/file_2_test.rb"
496
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
497
- f.contents <<-RB
498
- def test_name_2
499
- RB
500
- end
501
-
502
- searcher.mock_file do |f|
503
- f.path "/src/inline/gem/test/file_1_test.rb"
504
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
505
- f.contents <<-RB
506
- def test_name_1
507
- RB
508
- end
509
- end
510
-
511
- launch("test_name_1", searcher: searcher)
512
- assert_equal "cd /src/inline/gem && bundle exec ruby -I test /src/inline/gem/test/file_1_test.rb --name='/test_name_1/'", shell_mock.recall_exec
513
-
514
- launch("test_name_1 --all", searcher: searcher)
515
- assert_equal "cd /src && bundle exec ruby -I test -r bundler/setup -e \"ARGV.push('--name=/test_name_1/')\" -r /src/test/file_1_test.rb; cd -;\n\ncd /src/inline/gem && bundle exec ruby -I test -r bundler/setup -e \"ARGV.push('--name=/test_name_1/')\" -r /src/inline/gem/test/file_1_test.rb", shell_mock.recall_exec
516
-
517
- launch("file --all", searcher: searcher)
518
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb /src/test/file_2_test.rb; cd -;\n\ncd /src/inline/gem && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/inline/gem/test/file_1_test.rb", shell_mock.recall_exec
519
-
520
- launch("file_1", searcher: searcher)
521
- assert_equal "cd /src/inline/gem && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/inline/gem/test/file_1_test.rb", shell_mock.recall_exec
522
-
523
- launch("file_1 --all", searcher: searcher)
524
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb; cd -;\n\ncd /src/inline/gem && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/inline/gem/test/file_1_test.rb", shell_mock.recall_exec
525
- end
526
-
527
- def test__specified_example_name__simple
528
- searcher = MemorySearcher.new do |searcher|
529
- searcher.mock_file do |f|
530
- f.path "/src/test/file_1_test.rb"
531
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
532
- f.contents <<-RB
533
- def test_name_1
534
- RB
535
- end
536
-
537
- searcher.mock_file do |f|
538
- f.path "/src/inline/gem/test/file_2_test.rb"
539
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
540
- f.contents <<-RB
541
- def test_name_2
542
- RB
543
- end
544
- end
545
-
546
- launch("file_1 --name test_name_1", searcher: searcher)
547
- assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name='/test_name_1/'", shell_mock.recall_exec
548
-
549
- launch("file_2 --name test_name_2", searcher: searcher)
550
- assert_equal "cd /src/inline/gem && bundle exec ruby -I test /src/inline/gem/test/file_2_test.rb --name='/test_name_2/'", shell_mock.recall_exec
551
- end
552
-
553
- def test__specified_example_name__multiple_files_same_name
554
- searcher = MemorySearcher.new do |searcher|
555
- searcher.mock_file do |f|
556
- f.path "/src/test/file_1_test.rb"
557
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
558
- f.contents <<-RB
559
- def test_name_1
560
- RB
561
- end
562
-
563
- searcher.mock_file do |f|
564
- f.path "/src/inline/gem/test/file_1_test.rb"
565
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
566
- f.contents <<-RB
567
- def test_name_1
568
- RB
569
- end
570
- end
571
-
572
- launch("file_1 --name test_name_1", searcher: searcher)
573
- assert_equal "cd /src/inline/gem && bundle exec ruby -I test /src/inline/gem/test/file_1_test.rb --name='/test_name_1/'", shell_mock.recall_exec
574
- end
575
-
576
- def test__by_line_number
577
- searcher = MemorySearcher.new do |searcher|
578
- searcher.mock_file do |f|
579
- f.path "/src/test/file_1_test.rb"
580
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
581
- f.contents <<-RB
582
- class File1Test
583
- def test_name_1
584
- things
585
- end
586
-
587
- def test_name_2?
588
- things
589
- end
590
- end
591
- RB
592
- end
593
- end
594
-
595
- launch("file_1_test.rb:1", searcher: searcher)
596
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", shell_mock.recall_exec
597
-
598
- launch("file_1_test.rb:2", searcher: searcher)
599
- assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name='test_name_1'", shell_mock.recall_exec
600
-
601
- launch("file_1_test.rb:3", searcher: searcher)
602
- assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name='test_name_1'", shell_mock.recall_exec
603
-
604
- launch("file_1_test.rb:4", searcher: searcher)
605
- assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name='test_name_1'", shell_mock.recall_exec
606
-
607
- launch("file_1_test.rb:5", searcher: searcher)
608
- assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name='test_name_1'", shell_mock.recall_exec
609
-
610
- launch("file_1_test.rb:6", searcher: searcher)
611
- assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name='test_name_2?'", shell_mock.recall_exec
612
-
613
- launch("file_1_test.rb:7", searcher: searcher)
614
- assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name='test_name_2?'", shell_mock.recall_exec
615
-
616
- launch("file_1_test.rb:8", searcher: searcher)
617
- assert_equal "cd /src && bundle exec ruby -I test /src/test/file_1_test.rb --name='test_name_2?'", shell_mock.recall_exec
618
- end
619
-
620
- def test__by_line_number__multiple_files
621
- searcher = MemorySearcher.new do |searcher|
622
- searcher.mock_file do |f|
623
- f.path "/src/test/file_1_test.rb"
624
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
625
- f.contents <<-RB
626
- class File1Test
627
- def test_name_1
628
- RB
629
- end
630
-
631
- searcher.mock_file do |f|
632
- f.path "/src/inline/gem/test/file_1_test.rb"
633
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
634
- f.contents <<-RB
635
- class File1Test
636
- def test_name_1
637
- RB
638
- end
639
- end
640
-
641
- launch("file_1_test.rb:1", searcher: searcher)
642
- assert shell_mock.recall(:warn).first.first.to_s.match(/Open an issue/)
643
- end
644
-
645
- def test__by_line_number__file_contains_no_tests
646
- searcher = MemorySearcher.new do |searcher|
647
- searcher.mock_file do |f|
648
- f.path "/src/test/file_test.rb"
649
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
650
- f.contents <<-RB
651
- class File1Test
652
- end
653
- RB
654
- end
655
- end
656
-
657
- launch("file_test.rb:1", searcher: searcher)
658
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_test.rb", shell_mock.recall_exec
659
- end
660
-
661
- def test__rerun
662
- searcher = MemorySearcher.new do |searcher|
663
- searcher.mock_file do |f|
664
- f.path "/src/test/file_1_test.rb"
665
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
666
- end
667
-
668
- searcher.mock_file do |f|
669
- f.path "/src/test/file_2_test.rb"
670
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
671
- end
672
- end
673
-
674
- history_shell = Shell::HistoryRunner.new(shell: shell_mock, history_path: File.expand_path(File.join(__dir__, '../../tmp/test_history.log')))
675
-
676
- launch("file_1_test.rb", searcher: searcher, shell: history_shell)
677
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", history_shell.recall_exec
678
-
679
- launch("--rerun", searcher: searcher, shell: history_shell )
680
- assert_equal "cd /src && bundle exec ruby -I test -e 'ARGV.each {|f| require(f)}' /src/test/file_1_test.rb", history_shell.recall_exec
681
- end
682
- end
683
- end