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,126 +0,0 @@
1
- require "test_helper"
2
- require "test_helpers/mocks"
3
- require "test_launcher/queries"
4
-
5
- module TestLauncher
6
- module Queries
7
- class MultiPathQueryTest < TestCase
8
- include DefaultMocks
9
-
10
- def searcher
11
- @searcher ||= MockSearcher.new do |m|
12
- m.impl :test_files do |search_string|
13
- case search_string
14
- when "not_found"
15
- []
16
- when "file_1"
17
- ["file_1"]
18
- when "file_2"
19
- ["file_2"]
20
- when "files"
21
- ["file_3", "file_4"]
22
- else
23
- raise "can't find #{search_string}"
24
- end
25
- end
26
- end
27
- end
28
-
29
- def create_mock_request(**attrs)
30
- MockRequest.new(**attrs) do |m|
31
- m.impl(:test_case) do |file:, example: nil, request:|
32
- case file
33
- when "file_1"
34
- file_1_test_case
35
- when "file_2"
36
- file_2_test_case
37
- when "file_3"
38
- file_3_test_case
39
- when "file_4"
40
- file_4_test_case
41
- else
42
- raise "unmocked file: #{file}"
43
- end
44
- end
45
- end
46
- end
47
-
48
- def file_1_test_case
49
- @file_1_test_case ||= MockTestCase.new(file: "file_1", mtime: Time.now - 1)
50
- end
51
-
52
- def file_2_test_case
53
- @file_2_test_case ||= MockTestCase.new(file: "file_2", mtime: Time.now - 2)
54
- end
55
-
56
- def file_3_test_case
57
- @file_3_test_case ||= MockTestCase.new(file: "file_3", mtime: Time.now - 3)
58
- end
59
-
60
- def file_4_test_case
61
- @file_4_test_case ||= MockTestCase.new(file: "file_4", mtime: Time.now - 4)
62
- end
63
-
64
-
65
- def test_command__finds_files_for_0_of_2_terms_asdf
66
- request = create_mock_request(
67
- search_string: "not_found not_found",
68
- shell: default_shell,
69
- runner: default_runner,
70
- searcher: searcher
71
- )
72
- command = MultiPathQuery.new(request, default_command_finder).command
73
-
74
- assert_equal nil, command
75
- end
76
-
77
- def test_command__finds_files_for_1_of_2_terms
78
- request = create_mock_request(
79
- search_string: "file_1 not_found",
80
- shell: default_shell,
81
- runner: default_runner,
82
- searcher: searcher
83
- )
84
- command = MultiPathQuery.new(request, default_command_finder).command
85
-
86
- assert_equal nil, command
87
- end
88
-
89
- def test_command__finds_files_for_1_of_2_terms__warns
90
- request = create_mock_request(
91
- search_string: "file_1 not_found",
92
- shell: default_shell,
93
- searcher: searcher
94
- )
95
- command = MultiPathQuery.new(request, default_command_finder).command
96
-
97
- assert_equal 1, default_shell.recall(:warn).size
98
- end
99
-
100
- def test_command__finds_files_for_2_of_2_terms
101
- request = create_mock_request(
102
- search_string: "file_1 file_2",
103
- shell: default_shell,
104
- runner: default_runner,
105
- searcher: searcher,
106
- )
107
- command = MultiPathQuery.new(request, default_command_finder).command
108
-
109
- assert_equal [[[file_1_test_case, file_2_test_case]]], default_runner.recall(:multiple_files)
110
- assert_equal "multiple_files_return", command
111
- end
112
-
113
- def test_command__finds_files_for_2_of_2_terms__extra_files_found
114
- request = create_mock_request(
115
- search_string: "file_1 files",
116
- shell: default_shell,
117
- runner: default_runner,
118
- searcher: searcher,
119
- )
120
- command = MultiPathQuery.new(request, default_command_finder).command
121
- assert_equal [[[file_1_test_case, file_3_test_case, file_4_test_case]]], default_runner.recall(:multiple_files)
122
- assert_equal "multiple_files_return", command
123
- end
124
- end
125
- end
126
- end
@@ -1,192 +0,0 @@
1
- require "test_helper"
2
- require "test_helpers/mocks"
3
- require "test_launcher/queries"
4
-
5
- module TestLauncher
6
- module Queries
7
- class PathQueryTest < TestCase
8
- include DefaultMocks
9
-
10
- def searcher
11
- @searcher ||= MockSearcher.new do |m|
12
- m.impl :test_files do |search_string|
13
- case search_string
14
- when "not_found"
15
- []
16
- when "one_file"
17
- ["file_1"]
18
- when "multiple_files"
19
- ["file_2", "file_3", "file_4"]
20
- else
21
- raise "unmocked search_string: #{search_string}"
22
- end
23
- end
24
- end
25
- end
26
-
27
- def create_mock_request(**attrs)
28
- MockRequest.new(**attrs) do |m|
29
- m.impl(:test_case) do |file:, request:|
30
- case file
31
- when "file_1"
32
- normal_test_case
33
- when "file_2"
34
- old_test_case
35
- when "file_3"
36
- older_test_case
37
- when "file_4"
38
- new_test_case
39
- else
40
- raise "unmocked file: #{file}"
41
- end
42
- end
43
- end
44
- end
45
-
46
- def normal_test_case
47
- @normal_test_case ||= MockTestCase.new(file: "file_1")
48
- end
49
-
50
- def old_test_case
51
- @old_test_case ||= MockTestCase.new(file: "file_2", mtime: Time.now - 1000)
52
- end
53
-
54
- def older_test_case
55
- @older_test_case ||= MockTestCase.new(file: "file_3", mtime: Time.now - 10000)
56
- end
57
-
58
- def new_test_case
59
- @new_test_case ||= MockTestCase.new(file: "file_4", mtime: Time.now)
60
- end
61
-
62
- def test_command__file_not_found__returns_nil
63
- request = create_mock_request(
64
- search_string: "not_found",
65
- searcher: searcher
66
- )
67
-
68
- command = PathQuery.new(request, default_command_finder).command
69
-
70
- assert_equal nil, command
71
- end
72
-
73
- def test_command__file_not_found__does_not_warn
74
- request = create_mock_request(
75
- search_string: "not_found",
76
- searcher: searcher
77
- )
78
-
79
- command = PathQuery.new(request, default_command_finder).command
80
-
81
- assert default_shell.recall(:warn).empty?
82
- end
83
-
84
- def test_command__one_file_found__runs_single_file
85
- request = create_mock_request(
86
- search_string: "one_file",
87
- shell: default_shell,
88
- searcher: searcher,
89
- runner: default_runner
90
- )
91
-
92
- command = PathQuery.new(request, default_command_finder).command
93
-
94
- assert_equal [[normal_test_case]], default_runner.recall(:single_file)
95
- assert_equal "single_file_return", command
96
- end
97
-
98
- def test_command__one_file_found__has_correct_test_case
99
- request = create_mock_request(
100
- search_string: "one_file",
101
- shell: default_shell,
102
- searcher: searcher,
103
- runner: default_runner
104
- )
105
-
106
- expected_test_case_args = [file: "file_1", request: request]
107
-
108
- command = PathQuery.new(request, default_command_finder).command
109
-
110
- assert_equal [expected_test_case_args], request.recall(:test_case)
111
- end
112
-
113
- def test_command__one_file_found__notifies
114
- request = create_mock_request(
115
- search_string: "one_file",
116
- shell: default_shell,
117
- searcher: searcher,
118
- runner: default_runner
119
- )
120
-
121
- command = PathQuery.new(request, default_command_finder).command
122
-
123
- assert_equal [["Found 1 file."]], default_shell.recall(:notify)
124
- end
125
-
126
- def test_command__multiple_files_found__no_all__runs_single_file
127
- request = create_mock_request(
128
- search_string: "multiple_files",
129
- shell: default_shell,
130
- searcher: searcher,
131
- runner: default_runner,
132
- run_all?: false
133
- )
134
-
135
- command = PathQuery.new(request, default_command_finder).command
136
-
137
- assert_equal [[new_test_case]], default_runner.recall(:single_file)
138
- assert_equal "single_file_return", command
139
- end
140
-
141
- def test_command__multiple_files_found__no_all__notifies
142
- request = create_mock_request(
143
- search_string: "multiple_files",
144
- shell: default_shell,
145
- searcher: searcher,
146
- runner: default_runner,
147
- run_all?: false
148
- )
149
-
150
- command = PathQuery.new(request, default_command_finder).command
151
-
152
- messages = [
153
- ["Found 3 files."],
154
- ["Running most recently edited. Run with '--all' to run all the tests."]
155
- ]
156
- assert_equal messages, default_shell.recall(:notify)
157
- end
158
-
159
- def test_command__multiple_files_found__all__runs_single_file
160
- request = create_mock_request(
161
- search_string: "multiple_files",
162
- shell: default_shell,
163
- searcher: searcher,
164
- runner: default_runner,
165
- run_all?: true
166
- )
167
-
168
- command = PathQuery.new(request, default_command_finder).command
169
-
170
- assert_equal [[[old_test_case, older_test_case, new_test_case]]], default_runner.recall(:multiple_files)
171
- assert_equal "multiple_files_return", command
172
- end
173
-
174
- def test_command__multiple_files_found__all__notifies
175
- request = create_mock_request(
176
- search_string: "multiple_files",
177
- shell: default_shell,
178
- searcher: searcher,
179
- runner: default_runner,
180
- run_all?: true
181
- )
182
-
183
- command = PathQuery.new(request, default_command_finder).command
184
-
185
- messages = [
186
- ["Found 3 files."]
187
- ]
188
- assert_equal messages, default_shell.recall(:notify)
189
- end
190
- end
191
- end
192
- end
@@ -1,574 +0,0 @@
1
- require "test_helper"
2
- require "test_helpers/integration_helper"
3
-
4
- module TestLauncher
5
- class RspecIntegrationTest < TestCase
6
- include IntegrationHelper
7
-
8
- def launch(query, env: {}, searcher:, shell: shell_mock)
9
- query += " --framework rspec"
10
- shell.reset
11
- CLI.launch(query.split(" "), env, shell: shell, searcher: searcher)
12
- end
13
-
14
- def test__by_example__single_example
15
- searcher = MemorySearcher.new do |searcher|
16
- searcher.mock_file do |f|
17
- f.path "/src/spec/class_1_spec.rb"
18
- f.contents <<-RB
19
- it "does a thing" do
20
- RB
21
- end
22
- end
23
-
24
- launch("thing", searcher: searcher)
25
- assert_equal "cd /src && bundle exec rspec /src/spec/class_1_spec.rb --example thing", shell_mock.recall_exec
26
-
27
- launch("does a thing", searcher: searcher)
28
- assert_equal "cd /src && bundle exec rspec /src/spec/class_1_spec.rb --example does\\ a\\ thing", shell_mock.recall_exec
29
-
30
- launch("n", searcher: searcher)
31
- assert_equal "cd /src && bundle exec rspec /src/spec/class_1_spec.rb --example n", shell_mock.recall_exec
32
- end
33
-
34
- def test__by_example__multiple_examples__same_file
35
- searcher = MemorySearcher.new do |searcher|
36
- searcher.mock_file do |f|
37
- f.path "/src/spec/class_1_spec.rb"
38
- f.contents <<-RB
39
- it "name_1" do
40
- it "name_2" do
41
- end
42
- RB
43
- end
44
- end
45
-
46
- launch("name_", searcher: searcher)
47
- assert_equal "cd /src && bundle exec rspec /src/spec/class_1_spec.rb --example name_", shell_mock.recall_exec
48
- end
49
-
50
- def test__by_example__multiple_methods__different_files
51
- searcher = MemorySearcher.new do |searcher|
52
- searcher.mock_file do |f|
53
- f.path "/src/spec/class_1_spec.rb"
54
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
55
- f.contents <<-RB
56
- it "test_name_1" do
57
- it "test_name_2" do
58
- RB
59
- end
60
-
61
- searcher.mock_file do |f|
62
- f.path "/src/spec/class_2_spec.rb"
63
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
64
- f.contents <<-RB
65
- it "test_name_1" do
66
- it "test_name_2" do
67
- RB
68
- end
69
-
70
- searcher.mock_file do |f|
71
- f.path "/src/spec/class_3_spec.rb"
72
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
73
- f.contents <<-RB
74
- it "test_name_2" do
75
- RB
76
- end
77
- end
78
-
79
- launch("name_1", searcher: searcher)
80
- assert_equal "cd /src && bundle exec rspec /src/spec/class_2_spec.rb --example name_1", shell_mock.recall_exec
81
-
82
- launch("name_2", searcher: searcher)
83
- assert_equal "cd /src && bundle exec rspec /src/spec/class_2_spec.rb --example name_2", shell_mock.recall_exec
84
-
85
- launch("name_1 --all", searcher: searcher)
86
- assert_equal "cd /src && bundle exec rspec /src/spec/class_1_spec.rb /src/spec/class_2_spec.rb --example name_1", shell_mock.recall_exec
87
-
88
- launch("name_2 --all", searcher: searcher)
89
- assert_equal "cd /src && bundle exec rspec /src/spec/class_1_spec.rb /src/spec/class_2_spec.rb /src/spec/class_3_spec.rb --example name_2", shell_mock.recall_exec
90
- end
91
-
92
- def test__by_filename
93
- searcher = MemorySearcher.new do |searcher|
94
- searcher.mock_file do |f|
95
- f.path "/src/spec/file_1_spec.rb"
96
- f.contents ""
97
- end
98
- end
99
-
100
- launch("file_1", searcher: searcher)
101
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", shell_mock.recall_exec
102
-
103
- launch("file_1_spec.rb", searcher: searcher)
104
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", shell_mock.recall_exec
105
-
106
- launch("/file_1", searcher: searcher)
107
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", shell_mock.recall_exec
108
-
109
- launch(".rb", searcher: searcher)
110
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", shell_mock.recall_exec
111
-
112
- launch("/src/spec/file_1", searcher: searcher)
113
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", shell_mock.recall_exec
114
-
115
- launch("src/spec/file_1", searcher: searcher)
116
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", shell_mock.recall_exec
117
-
118
- launch("ec/file_1", searcher: searcher)
119
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", shell_mock.recall_exec
120
- end
121
-
122
- def test__by_filename__multiple_files_found
123
- searcher = MemorySearcher.new do |searcher|
124
- searcher.mock_file do |f|
125
- f.path "/src/spec/file_1_spec.rb"
126
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
127
- end
128
-
129
- searcher.mock_file do |f|
130
- f.path "/src/spec/file_2_spec.rb"
131
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
132
- end
133
-
134
- searcher.mock_file do |f|
135
- f.path "/src/spec/file_3_spec.rb"
136
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
137
- end
138
-
139
- searcher.mock_file do |f|
140
- f.path "/src/spec/other_spec.rb"
141
- end
142
- end
143
-
144
- launch("file_1", searcher: searcher)
145
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", shell_mock.recall_exec
146
-
147
- launch("file", searcher: searcher)
148
- assert_equal "cd /src && bundle exec rspec /src/spec/file_2_spec.rb", shell_mock.recall_exec
149
-
150
- launch("file --all", searcher: searcher)
151
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb /src/spec/file_2_spec.rb /src/spec/file_3_spec.rb", shell_mock.recall_exec
152
- end
153
-
154
- def test__by_filename__preferred_over_regex_and_test_name_matches
155
- searcher = MemorySearcher.new do |searcher|
156
- searcher.mock_file do |f|
157
- f.path "/src/spec/class_1_spec.rb"
158
- f.contents <<-RB
159
- it "name_spec" do
160
- RB
161
- end
162
-
163
- searcher.mock_file do |f|
164
- f.path "/src/spec/name_spec.rb"
165
- end
166
-
167
- searcher.mock_file do |f|
168
- f.path "/src/spec/other_spec.rb"
169
- f.contents <<-RB
170
- regex will match name_spec
171
- RB
172
- end
173
- end
174
-
175
- launch("name_spec", searcher: searcher)
176
- assert_equal "cd /src && bundle exec rspec /src/spec/name_spec.rb", shell_mock.recall_exec
177
- end
178
-
179
- def test__multiple_queries__generic_regex__prefers_to_keep_spaces
180
- searcher = MemorySearcher.new do |searcher|
181
- searcher.mock_file do |f|
182
- f.path "/src/spec/file_1_spec.rb"
183
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
184
- f.contents <<-RB
185
- this matches
186
- RB
187
- end
188
-
189
- searcher.mock_file do |f|
190
- f.path "/src/spec/file_2_spec.rb"
191
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
192
- f.contents <<-RB
193
- this
194
- matches
195
- RB
196
- end
197
-
198
- launch("this matches", searcher: searcher)
199
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", shell_mock.recall_exec
200
-
201
- launch("this matches --all", searcher: searcher)
202
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", shell_mock.recall_exec
203
-
204
- launch("matches this --all", searcher: searcher)
205
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb /src/spec/file_2_spec.rb", shell_mock.recall_exec
206
- end
207
- end
208
-
209
- def test__multiple_queries__splits_spaces_for_test_names
210
- searcher = MemorySearcher.new do |searcher|
211
- searcher.mock_file do |f|
212
- f.path "/src/spec/file_1_spec.rb"
213
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
214
- f.contents <<-RB
215
- it "this" do
216
- RB
217
- end
218
-
219
- searcher.mock_file do |f|
220
- f.path "/src/spec/file_2_spec.rb"
221
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
222
- f.contents <<-RB
223
- it "matches" do
224
- RB
225
- end
226
-
227
- launch("this matches", searcher: searcher)
228
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb /src/spec/file_2_spec.rb --example this\\|matches", shell_mock.recall_exec
229
-
230
- skip "not supported in rspec yet"
231
- launch("this matches --all", searcher: searcher)
232
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb /src/spec/file_2_spec.rb --example this\\|matches", shell_mock.recall_exec
233
-
234
- launch("matches this --all", searcher: searcher)
235
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb /src/spec/file_2_spec.rb --example this\\|matches", shell_mock.recall_exec
236
- end
237
- end
238
-
239
- def test__by_multiple_filenames__multiple_files_found
240
- searcher = MemorySearcher.new do |searcher|
241
- searcher.mock_file do |f|
242
- f.path "/src/spec/file_1_spec.rb"
243
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
244
- f.contents ""
245
- end
246
-
247
- searcher.mock_file do |f|
248
- f.path "/src/spec/file_2_spec.rb"
249
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
250
- f.contents ""
251
- end
252
-
253
- searcher.mock_file do |f|
254
- f.path "/src/spec/file_3_spec.rb"
255
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
256
- f.contents ""
257
- end
258
-
259
- searcher.mock_file do |f|
260
- f.path "/src/spec/other_tspecrb"
261
- f.contents ""
262
- end
263
- end
264
-
265
- launch("file_1 file_2", searcher: searcher)
266
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb /src/spec/file_2_spec.rb", shell_mock.recall_exec
267
-
268
- launch("file_1 file", searcher: searcher)
269
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb /src/spec/file_2_spec.rb /src/spec/file_3_spec.rb", shell_mock.recall_exec
270
-
271
- # If multiple queries are submitted but not all of them match,
272
- # then what should we do? For now, we assume that it's only
273
- # considered a match if each query term matches at least one
274
- # or more files.
275
- launch("file_1 gibberish", searcher: searcher)
276
- assert_equal nil, shell_mock.recall_exec
277
- end
278
-
279
- def test__by_regex__one_match
280
- searcher = MemorySearcher.new do |searcher|
281
- searcher.mock_file do |f|
282
- f.path "/src/spec/file_1_spec.rb"
283
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
284
- f.contents <<-RB
285
- regex match 1
286
- regex match 2
287
- regex match 3
288
- RB
289
- end
290
-
291
- searcher.mock_file do |f|
292
- f.path "/src/spec/file_2_spec.rb"
293
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
294
- f.contents <<-RB
295
- regex match 1
296
- regex match 2
297
- RB
298
- end
299
-
300
- searcher.mock_file do |f|
301
- f.path "/src/spec/file_3_spec.rb"
302
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
303
- f.contents <<-RB
304
- regex match 1
305
- regex match 3
306
- RB
307
- end
308
- end
309
-
310
- launch("regex match 1", searcher: searcher)
311
- assert_equal "cd /src && bundle exec rspec /src/spec/file_2_spec.rb", shell_mock.recall_exec
312
-
313
- launch("regex match 3", searcher: searcher)
314
- assert_equal "cd /src && bundle exec rspec /src/spec/file_3_spec.rb", shell_mock.recall_exec
315
-
316
- launch("regex match", searcher: searcher)
317
- assert_equal "cd /src && bundle exec rspec /src/spec/file_2_spec.rb", shell_mock.recall_exec
318
-
319
- launch("regex match --all", searcher: searcher)
320
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb /src/spec/file_2_spec.rb /src/spec/file_3_spec.rb", shell_mock.recall_exec
321
- end
322
-
323
- def test__by_example__preferred_over_regex
324
- searcher = MemorySearcher.new do |searcher|
325
- searcher.mock_file do |f|
326
- f.path "/src/spec/file_1_spec.rb"
327
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
328
- f.contents <<-RB
329
- it "regex_match" do
330
- RB
331
- end
332
-
333
- searcher.mock_file do |f|
334
- f.path "/src/spec/file_2_spec.rb"
335
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
336
- f.contents <<-RB
337
- regex_match
338
- RB
339
- end
340
- end
341
-
342
- launch("regex_match", searcher: searcher)
343
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example regex_match", shell_mock.recall_exec
344
- end
345
-
346
- def test__context_blocks_are_treated_as_examples
347
- searcher = MemorySearcher.new do |searcher|
348
- searcher.mock_file do |f|
349
- f.path "/src/spec/file_1_spec.rb"
350
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
351
- f.contents <<-RB
352
- describe "test_1" do
353
- context "test_2" do
354
- RSpec.describe "test_3" do
355
- RB
356
- end
357
- end
358
-
359
- launch("test_1", searcher: searcher)
360
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example test_1", shell_mock.recall_exec
361
-
362
- launch("test_2", searcher: searcher)
363
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example test_2", shell_mock.recall_exec
364
-
365
- launch("test_3", searcher: searcher)
366
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example test_3", shell_mock.recall_exec
367
- end
368
-
369
- def test__by_example__handles_regex_for_example_name
370
- searcher = MemorySearcher.new do |searcher|
371
- searcher.mock_file do |f|
372
- f.path "/src/spec/file_1_spec.rb"
373
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
374
- f.contents <<-RB
375
- it "test_name_1" do
376
- RB
377
- end
378
-
379
- searcher.mock_file do |f|
380
- f.path "/src/spec/file_2_spec.rb"
381
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
382
- f.contents <<-RB
383
- it "test_name_2" do
384
- RB
385
- end
386
- end
387
-
388
- launch("test_name_1x?", searcher: searcher)
389
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example test_name_1x\\?", shell_mock.recall_exec
390
-
391
- launch("test_name_2|test_name_1", searcher: searcher)
392
- assert_equal "cd /src && bundle exec rspec /src/spec/file_2_spec.rb --example test_name_2\\|test_name_1", shell_mock.recall_exec
393
-
394
- launch('test_name_\d', searcher: searcher)
395
- assert_equal "cd /src && bundle exec rspec /src/spec/file_2_spec.rb --example test_name_\\\\d", shell_mock.recall_exec
396
-
397
- launch('test_name_\d --all', searcher: searcher)
398
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb /src/spec/file_2_spec.rb --example test_name_\\\\d", shell_mock.recall_exec
399
- end
400
-
401
- def test__not_found
402
- searcher = MemorySearcher.new do |searcher|
403
- searcher.mock_file do |f|
404
- f.path "/src/spec/file_1_spec.rb"
405
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
406
- f.contents <<-RB
407
- some stuff
408
- RB
409
- end
410
- end
411
-
412
- launch("gibberish", searcher: searcher)
413
- assert_equal nil, shell_mock.recall_exec
414
- end
415
-
416
- def test__different_roots
417
- searcher = MemorySearcher.new do |searcher|
418
- searcher.mock_file do |f|
419
- f.path "/src/spec/file_1_spec.rb"
420
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
421
- f.contents <<-RB
422
- it 'test_name_1' do
423
- RB
424
- end
425
-
426
- searcher.mock_file do |f|
427
- f.path "/src/spec/file_2_spec.rb"
428
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
429
- f.contents <<-RB
430
- it 'test_name_2' do
431
- RB
432
- end
433
-
434
- searcher.mock_file do |f|
435
- f.path "/src/inline/gem/spec/file_1_spec.rb"
436
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
437
- f.contents <<-RB
438
- it 'test_name_1' do
439
- RB
440
- end
441
- end
442
-
443
- launch("test_name_1", searcher: searcher)
444
- assert_equal "cd /src/inline/gem && bundle exec rspec /src/inline/gem/spec/file_1_spec.rb --example test_name_1", shell_mock.recall_exec
445
-
446
- launch("test_name_1 --all", searcher: searcher)
447
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example test_name_1; cd -;\n\ncd /src/inline/gem && bundle exec rspec /src/inline/gem/spec/file_1_spec.rb --example test_name_1", shell_mock.recall_exec
448
-
449
- launch("file --all", searcher: searcher)
450
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb /src/spec/file_2_spec.rb; cd -;\n\ncd /src/inline/gem && bundle exec rspec /src/inline/gem/spec/file_1_spec.rb", shell_mock.recall_exec
451
-
452
- launch("file_1", searcher: searcher)
453
- assert_equal "cd /src/inline/gem && bundle exec rspec /src/inline/gem/spec/file_1_spec.rb", shell_mock.recall_exec
454
-
455
- launch("file_1 --all", searcher: searcher)
456
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb; cd -;\n\ncd /src/inline/gem && bundle exec rspec /src/inline/gem/spec/file_1_spec.rb", shell_mock.recall_exec
457
- end
458
-
459
- def test__specified_example_name__simple
460
- searcher = MemorySearcher.new do |searcher|
461
- searcher.mock_file do |f|
462
- f.path "/src/spec/file_1_spec.rb"
463
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
464
- f.contents <<-RB
465
- it "test_name_1" do
466
- RB
467
- end
468
-
469
- searcher.mock_file do |f|
470
- f.path "/src/inline/gem/spec/file_2_spec.rb"
471
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
472
- f.contents <<-RB
473
- it "test_name_2" do
474
- RB
475
- end
476
- end
477
-
478
- launch("file_1 --name test_name_1", searcher: searcher)
479
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example test_name_1", shell_mock.recall_exec
480
-
481
- launch("file_2 --name test_name_2", searcher: searcher)
482
- assert_equal "cd /src/inline/gem && bundle exec rspec /src/inline/gem/spec/file_2_spec.rb --example test_name_2", shell_mock.recall_exec
483
-
484
- launch("file_1 --example test_name_1", searcher: searcher)
485
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example test_name_1", shell_mock.recall_exec
486
- end
487
-
488
- def test__specified_example_name__multiple_files_same_name
489
- searcher = MemorySearcher.new do |searcher|
490
- searcher.mock_file do |f|
491
- f.path "/src/spec/file_1_spec.rb"
492
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
493
- f.contents <<-RB
494
- it "test_name_1" do
495
- RB
496
- end
497
-
498
- searcher.mock_file do |f|
499
- f.path "/src/inline/gem/spec/file_1_spec.rb"
500
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
501
- f.contents <<-RB
502
- it "test_name_1" do
503
- RB
504
- end
505
- end
506
-
507
- launch("file_1_spec.rb --name test_name_1", searcher: searcher)
508
- assert_equal "cd /src/inline/gem && bundle exec rspec /src/inline/gem/spec/file_1_spec.rb --example test_name_1", shell_mock.recall_exec
509
-
510
- launch("file_1 --name test_name_1", searcher: searcher)
511
- assert_equal "cd /src/inline/gem && bundle exec rspec /src/inline/gem/spec/file_1_spec.rb --example test_name_1", shell_mock.recall_exec
512
- end
513
-
514
- def test__by_line_number__just_passes_through_to_rspec
515
- searcher = MemorySearcher.new do |searcher|
516
- searcher.mock_file do |f|
517
- f.path "/src/spec/file_1_spec.rb"
518
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
519
- f.contents ""
520
- end
521
- end
522
-
523
- launch("file_1_spec.rb:1", searcher: searcher)
524
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb:1", shell_mock.recall_exec
525
-
526
- launch("/src/spec/file_1_spec.rb:1", searcher: searcher)
527
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb:1", shell_mock.recall_exec
528
-
529
- launch("file_1_spec.rb:273", searcher: searcher)
530
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb:273", shell_mock.recall_exec
531
- end
532
-
533
- def test__by_line_number__multiple_files
534
- searcher = MemorySearcher.new do |searcher|
535
- searcher.mock_file do |f|
536
- f.path "/src/spec/file_1_spec.rb"
537
- f.mtime Time.new(2013, 01, 01, 00, 00, 00)
538
- f.contents ""
539
- end
540
-
541
- searcher.mock_file do |f|
542
- f.path "/src/inline/gem/spec/file_1_spec.rb"
543
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
544
- f.contents ""
545
- end
546
- end
547
-
548
- launch("file_1_spec.rb:1", searcher: searcher)
549
- assert_equal "cd /src/inline/gem && bundle exec rspec /src/inline/gem/spec/file_1_spec.rb:1", shell_mock.recall_exec
550
- end
551
-
552
- def test__rerun
553
- searcher = MemorySearcher.new do |searcher|
554
- searcher.mock_file do |f|
555
- f.path "/src/spec/file_1_spec.rb"
556
- f.mtime Time.new(2014, 01, 01, 00, 00, 00)
557
- end
558
-
559
- searcher.mock_file do |f|
560
- f.path "/src/spec/file_2_spec.rb"
561
- f.mtime Time.new(2015, 01, 01, 00, 00, 00)
562
- end
563
- end
564
-
565
- history_shell = Shell::HistoryRunner.new(shell: shell_mock, history_path: File.expand_path(File.join(__dir__, '../../tmp/test_history.log')))
566
-
567
- launch("file_1_spec.rb", searcher: searcher, shell: history_shell)
568
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", history_shell.recall_exec
569
-
570
- launch("--rerun", searcher: searcher, shell: history_shell)
571
- assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb", history_shell.recall_exec
572
- end
573
- end
574
- end