test_launcher 1.5.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +81 -37
- data/lib/test_launcher/cli.rb +1 -3
- data/lib/test_launcher/cli/input_parser.rb +10 -6
- data/lib/test_launcher/frameworks/base.rb +11 -0
- data/lib/test_launcher/frameworks/{elixir.rb → ex_unit.rb} +16 -20
- data/lib/test_launcher/frameworks/minitest.rb +29 -17
- data/lib/test_launcher/frameworks/rspec.rb +14 -7
- data/lib/test_launcher/queries.rb +47 -31
- data/lib/test_launcher/shell/runner.rb +2 -1
- data/lib/test_launcher/version.rb +1 -1
- data/test/test_helpers/integration_helper.rb +6 -13
- data/test/test_helpers/mocks.rb +1 -0
- data/test/test_helpers/mocks/searcher_mock.rb +3 -1
- data/test/test_launcher/ex_unit_integration_test.rb +392 -0
- data/test/test_launcher/fixtures/minitest/test/class_1_test.rb +4 -15
- data/test/test_launcher/fixtures/minitest/test/class_2_test.rb +7 -3
- data/test/test_launcher/frameworks/minitest/runner_test.rb +10 -10
- data/test/test_launcher/frameworks/minitest/searcher_test.rb +11 -10
- data/test/test_launcher/frameworks/rspec/runner_test.rb +5 -5
- data/test/test_launcher/frameworks/rspec/searcher_test.rb +4 -4
- data/test/test_launcher/minitest_integration_test.rb +533 -38
- data/test/test_launcher/queries/example_name_query_test.rb +5 -1
- data/test/test_launcher/queries/line_number_query_test.rb +7 -7
- data/test/test_launcher/queries/multi_term_query_test.rb +0 -12
- data/test/test_launcher/rspec_integration_test.rb +458 -35
- metadata +5 -5
- data/test/test_launcher/queries/specified_name_query_test.rb +0 -112
@@ -78,6 +78,10 @@ module TestLauncher
|
|
78
78
|
m.impl :multiple_files do |test_cases|
|
79
79
|
"multiple_files #{test_cases.map(&:file).join(" ")}"
|
80
80
|
end
|
81
|
+
|
82
|
+
m.impl :multiple_examples do |test_cases|
|
83
|
+
"multiple_examples #{test_cases.map(&:file).join(" ")}"
|
84
|
+
end
|
81
85
|
end
|
82
86
|
end
|
83
87
|
|
@@ -193,7 +197,7 @@ module TestLauncher
|
|
193
197
|
|
194
198
|
command = ExampleNameQuery.new(request, default_command_finder).command
|
195
199
|
|
196
|
-
assert_equal "
|
200
|
+
assert_equal "multiple_examples file_1_test.rb file_2_test.rb", command
|
197
201
|
end
|
198
202
|
|
199
203
|
def test_command__multiple_examples__multiple_files__all__notifies
|
@@ -12,11 +12,11 @@ module TestLauncher
|
|
12
12
|
m.impl :by_line do |file, line_number|
|
13
13
|
case [file, line_number]
|
14
14
|
when ["not_found", 1]
|
15
|
-
|
15
|
+
[]
|
16
16
|
when ["found", 17]
|
17
|
-
{file: "found", example_name: "test_example", line_number: 14}
|
17
|
+
[{file: "found", example_name: "test_example", line_number: 14}]
|
18
18
|
when ["found", 1]
|
19
|
-
{file: "found"}
|
19
|
+
[{file: "found"}]
|
20
20
|
when ["found", 9999]
|
21
21
|
raise "invalid line number"
|
22
22
|
when ["multiple", 1]
|
@@ -82,9 +82,9 @@ module TestLauncher
|
|
82
82
|
|
83
83
|
command = LineNumberQuery.new(request, default_command_finder).command
|
84
84
|
|
85
|
-
assert_equal [[whole_file_test_case]], default_runner.recall(:
|
85
|
+
assert_equal [[whole_file_test_case]], default_runner.recall(:by_line_number)
|
86
86
|
|
87
|
-
assert_equal "
|
87
|
+
assert_equal "by_line_number_return", command
|
88
88
|
end
|
89
89
|
|
90
90
|
|
@@ -98,9 +98,9 @@ module TestLauncher
|
|
98
98
|
|
99
99
|
command = LineNumberQuery.new(request, default_command_finder).command
|
100
100
|
|
101
|
-
assert_equal [[example_name_test_case]], default_runner.recall(:
|
101
|
+
assert_equal [[example_name_test_case]], default_runner.recall(:by_line_number)
|
102
102
|
|
103
|
-
assert_equal "
|
103
|
+
assert_equal "by_line_number_return", command
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
@@ -74,18 +74,6 @@ module TestLauncher
|
|
74
74
|
assert_equal nil, command
|
75
75
|
end
|
76
76
|
|
77
|
-
def test_command__finds_files_for_0_of_2_terms__warns
|
78
|
-
request = create_mock_request(
|
79
|
-
search_string: "not_found not_found",
|
80
|
-
shell: default_shell,
|
81
|
-
runner: default_runner,
|
82
|
-
searcher: searcher
|
83
|
-
)
|
84
|
-
command = MultiTermQuery.new(request, default_command_finder).command
|
85
|
-
|
86
|
-
assert_equal 1, default_shell.recall(:warn).size
|
87
|
-
end
|
88
|
-
|
89
77
|
def test_command__finds_files_for_1_of_2_terms
|
90
78
|
request = create_mock_request(
|
91
79
|
search_string: "file_1 not_found",
|
@@ -5,65 +5,488 @@ module TestLauncher
|
|
5
5
|
class RspecIntegrationTest < TestCase
|
6
6
|
include IntegrationHelper
|
7
7
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
8
|
+
def launch(query, env: {}, searcher:)
|
9
|
+
query += " --framework rspec"
|
10
|
+
shell_mock.reset
|
11
|
+
CLI.launch(query.split(" "), env, shell: shell_mock, searcher: searcher)
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
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
|
16
32
|
end
|
17
33
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
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
|
21
48
|
end
|
22
49
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
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", 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", shell_mock.recall_exec
|
26
90
|
end
|
27
91
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
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
|
31
120
|
end
|
32
121
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
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
|
36
152
|
end
|
37
153
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
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
|
41
177
|
end
|
42
178
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
179
|
+
def test__by_multiple_filenames__multiple_files_found
|
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 ""
|
185
|
+
end
|
186
|
+
|
187
|
+
searcher.mock_file do |f|
|
188
|
+
f.path "/src/spec/file_2_spec.rb"
|
189
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
190
|
+
f.contents ""
|
191
|
+
end
|
192
|
+
|
193
|
+
searcher.mock_file do |f|
|
194
|
+
f.path "/src/spec/file_3_spec.rb"
|
195
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
196
|
+
f.contents ""
|
197
|
+
end
|
198
|
+
|
199
|
+
searcher.mock_file do |f|
|
200
|
+
f.path "/src/spec/other_tspecrb"
|
201
|
+
f.contents ""
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
launch("file_1 file_2", searcher: searcher)
|
206
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb /src/spec/file_2_spec.rb", shell_mock.recall_exec
|
207
|
+
|
208
|
+
launch("file_1 file", searcher: searcher)
|
209
|
+
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
|
210
|
+
|
211
|
+
# If multiple queries are submitted but not all of them match,
|
212
|
+
# then what should we do? For now, we assume that it's only
|
213
|
+
# considered a match if each query term matches at least one
|
214
|
+
# or more files.
|
215
|
+
launch("file_1 gibberish", searcher: searcher)
|
216
|
+
assert_equal nil, shell_mock.recall_exec
|
46
217
|
end
|
47
218
|
|
48
|
-
def
|
49
|
-
|
50
|
-
|
219
|
+
def test__by_regex__one_match
|
220
|
+
searcher = MemorySearcher.new do |searcher|
|
221
|
+
searcher.mock_file do |f|
|
222
|
+
f.path "/src/spec/file_1_spec.rb"
|
223
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
224
|
+
f.contents <<-RB
|
225
|
+
regex match 1
|
226
|
+
regex match 2
|
227
|
+
regex match 3
|
228
|
+
RB
|
229
|
+
end
|
230
|
+
|
231
|
+
searcher.mock_file do |f|
|
232
|
+
f.path "/src/spec/file_2_spec.rb"
|
233
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
234
|
+
f.contents <<-RB
|
235
|
+
regex match 1
|
236
|
+
regex match 2
|
237
|
+
RB
|
238
|
+
end
|
239
|
+
|
240
|
+
searcher.mock_file do |f|
|
241
|
+
f.path "/src/spec/file_3_spec.rb"
|
242
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
243
|
+
f.contents <<-RB
|
244
|
+
regex match 1
|
245
|
+
regex match 3
|
246
|
+
RB
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
launch("regex match 1", searcher: searcher)
|
251
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_2_spec.rb", shell_mock.recall_exec
|
252
|
+
|
253
|
+
launch("regex match 3", searcher: searcher)
|
254
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_3_spec.rb", shell_mock.recall_exec
|
255
|
+
|
256
|
+
launch("regex match", searcher: searcher)
|
257
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_2_spec.rb", shell_mock.recall_exec
|
258
|
+
|
259
|
+
launch("regex match --all", searcher: searcher)
|
260
|
+
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
|
51
261
|
end
|
52
262
|
|
53
|
-
def
|
54
|
-
|
55
|
-
|
56
|
-
|
263
|
+
def test__by_example__preferred_over_regex
|
264
|
+
searcher = MemorySearcher.new do |searcher|
|
265
|
+
searcher.mock_file do |f|
|
266
|
+
f.path "/src/spec/file_1_spec.rb"
|
267
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
268
|
+
f.contents <<-RB
|
269
|
+
it "regex_match" do
|
270
|
+
RB
|
271
|
+
end
|
272
|
+
|
273
|
+
searcher.mock_file do |f|
|
274
|
+
f.path "/src/spec/file_2_spec.rb"
|
275
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
276
|
+
f.contents <<-RB
|
277
|
+
regex_match
|
278
|
+
RB
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
launch("regex_match", searcher: searcher)
|
283
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example regex_match", shell_mock.recall_exec
|
57
284
|
end
|
58
285
|
|
59
|
-
def
|
60
|
-
|
61
|
-
|
286
|
+
def test__context_blocks_are_treated_as_examples
|
287
|
+
searcher = MemorySearcher.new do |searcher|
|
288
|
+
searcher.mock_file do |f|
|
289
|
+
f.path "/src/spec/file_1_spec.rb"
|
290
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
291
|
+
f.contents <<-RB
|
292
|
+
describe "test_1" do
|
293
|
+
context "test_2" do
|
294
|
+
RSpec.describe "test_3" do
|
295
|
+
RB
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
launch("test_1", searcher: searcher)
|
300
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example test_1", shell_mock.recall_exec
|
301
|
+
|
302
|
+
launch("test_2", searcher: searcher)
|
303
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example test_2", shell_mock.recall_exec
|
304
|
+
|
305
|
+
launch("test_3", searcher: searcher)
|
306
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example test_3", shell_mock.recall_exec
|
307
|
+
end
|
308
|
+
|
309
|
+
def test__by_example__handles_regex_for_example_name
|
310
|
+
searcher = MemorySearcher.new do |searcher|
|
311
|
+
searcher.mock_file do |f|
|
312
|
+
f.path "/src/spec/file_1_spec.rb"
|
313
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
314
|
+
f.contents <<-RB
|
315
|
+
it "test_name_1" do
|
316
|
+
RB
|
317
|
+
end
|
318
|
+
|
319
|
+
searcher.mock_file do |f|
|
320
|
+
f.path "/src/spec/file_2_spec.rb"
|
321
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
322
|
+
f.contents <<-RB
|
323
|
+
it "test_name_2" do
|
324
|
+
RB
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
launch("test_name_1x?", searcher: searcher)
|
329
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example test_name_1x\\?", shell_mock.recall_exec
|
330
|
+
|
331
|
+
launch("test_name_2|test_name_1", searcher: searcher)
|
332
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_2_spec.rb --example test_name_2\\|test_name_1", shell_mock.recall_exec
|
333
|
+
|
334
|
+
launch('test_name_\d', searcher: searcher)
|
335
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_2_spec.rb --example test_name_\\\\d", shell_mock.recall_exec
|
336
|
+
|
337
|
+
launch('test_name_\d --all', searcher: searcher)
|
338
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb /src/spec/file_2_spec.rb", shell_mock.recall_exec
|
62
339
|
end
|
63
340
|
|
64
341
|
def test__not_found
|
65
|
-
|
342
|
+
searcher = MemorySearcher.new do |searcher|
|
343
|
+
searcher.mock_file do |f|
|
344
|
+
f.path "/src/spec/file_1_spec.rb"
|
345
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
346
|
+
f.contents <<-RB
|
347
|
+
some stuff
|
348
|
+
RB
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
launch("gibberish", searcher: searcher)
|
66
353
|
assert_equal nil, shell_mock.recall_exec
|
67
354
|
end
|
355
|
+
|
356
|
+
def test__different_roots
|
357
|
+
searcher = MemorySearcher.new do |searcher|
|
358
|
+
searcher.mock_file do |f|
|
359
|
+
f.path "/src/spec/file_1_spec.rb"
|
360
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
361
|
+
f.contents <<-RB
|
362
|
+
it 'test_name_1' do
|
363
|
+
RB
|
364
|
+
end
|
365
|
+
|
366
|
+
searcher.mock_file do |f|
|
367
|
+
f.path "/src/spec/file_2_spec.rb"
|
368
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
369
|
+
f.contents <<-RB
|
370
|
+
it 'test_name_2' do
|
371
|
+
RB
|
372
|
+
end
|
373
|
+
|
374
|
+
searcher.mock_file do |f|
|
375
|
+
f.path "/src/inline/gem/spec/file_1_spec.rb"
|
376
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
377
|
+
f.contents <<-RB
|
378
|
+
it 'test_name_1' do
|
379
|
+
RB
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
launch("test_name_1", searcher: searcher)
|
384
|
+
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
|
385
|
+
|
386
|
+
launch("test_name_1 --all", searcher: searcher)
|
387
|
+
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
|
388
|
+
|
389
|
+
launch("file --all", searcher: searcher)
|
390
|
+
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
|
391
|
+
|
392
|
+
launch("file_1", searcher: searcher)
|
393
|
+
assert_equal "cd /src/inline/gem && bundle exec rspec /src/inline/gem/spec/file_1_spec.rb", shell_mock.recall_exec
|
394
|
+
|
395
|
+
launch("file_1 --all", searcher: searcher)
|
396
|
+
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
|
397
|
+
end
|
398
|
+
|
399
|
+
def test__specified_example_name__simple
|
400
|
+
searcher = MemorySearcher.new do |searcher|
|
401
|
+
searcher.mock_file do |f|
|
402
|
+
f.path "/src/spec/file_1_spec.rb"
|
403
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
404
|
+
f.contents <<-RB
|
405
|
+
it "test_name_1" do
|
406
|
+
RB
|
407
|
+
end
|
408
|
+
|
409
|
+
searcher.mock_file do |f|
|
410
|
+
f.path "/src/inline/gem/spec/file_2_spec.rb"
|
411
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
412
|
+
f.contents <<-RB
|
413
|
+
it "test_name_2" do
|
414
|
+
RB
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
launch("file_1 --name test_name_1", searcher: searcher)
|
419
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example test_name_1", shell_mock.recall_exec
|
420
|
+
|
421
|
+
launch("file_2 --name test_name_2", searcher: searcher)
|
422
|
+
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
|
423
|
+
|
424
|
+
launch("file_1 --example test_name_1", searcher: searcher)
|
425
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb --example test_name_1", shell_mock.recall_exec
|
426
|
+
end
|
427
|
+
|
428
|
+
def test__specified_example_name__multiple_files_same_name
|
429
|
+
searcher = MemorySearcher.new do |searcher|
|
430
|
+
searcher.mock_file do |f|
|
431
|
+
f.path "/src/spec/file_1_spec.rb"
|
432
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
433
|
+
f.contents <<-RB
|
434
|
+
it "test_name_1" do
|
435
|
+
RB
|
436
|
+
end
|
437
|
+
|
438
|
+
searcher.mock_file do |f|
|
439
|
+
f.path "/src/inline/gem/spec/file_1_spec.rb"
|
440
|
+
f.mtime Time.new(2015, 01, 01, 00, 00, 00)
|
441
|
+
f.contents <<-RB
|
442
|
+
it "test_name_1" do
|
443
|
+
RB
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
launch("file_1_spec.rb --name test_name_1", searcher: searcher)
|
448
|
+
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
|
449
|
+
|
450
|
+
launch("file_1 --name test_name_1", searcher: searcher)
|
451
|
+
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
|
452
|
+
end
|
453
|
+
|
454
|
+
def test__by_line_number__just_passes_through_to_rspec
|
455
|
+
searcher = MemorySearcher.new do |searcher|
|
456
|
+
searcher.mock_file do |f|
|
457
|
+
f.path "/src/spec/file_1_spec.rb"
|
458
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
459
|
+
f.contents ""
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
launch("file_1_spec.rb:1", searcher: searcher)
|
464
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb:1", shell_mock.recall_exec
|
465
|
+
|
466
|
+
launch("/src/spec/file_1_spec.rb:1", searcher: searcher)
|
467
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb:1", shell_mock.recall_exec
|
468
|
+
|
469
|
+
launch("file_1_spec.rb:273", searcher: searcher)
|
470
|
+
assert_equal "cd /src && bundle exec rspec /src/spec/file_1_spec.rb:273", shell_mock.recall_exec
|
471
|
+
end
|
472
|
+
|
473
|
+
def test__by_line_number__multiple_files
|
474
|
+
searcher = MemorySearcher.new do |searcher|
|
475
|
+
searcher.mock_file do |f|
|
476
|
+
f.path "/src/spec/file_1_spec.rb"
|
477
|
+
f.mtime Time.new(2013, 01, 01, 00, 00, 00)
|
478
|
+
f.contents ""
|
479
|
+
end
|
480
|
+
|
481
|
+
searcher.mock_file do |f|
|
482
|
+
f.path "/src/inline/gem/spec/file_1_spec.rb"
|
483
|
+
f.mtime Time.new(2014, 01, 01, 00, 00, 00)
|
484
|
+
f.contents ""
|
485
|
+
end
|
486
|
+
end
|
487
|
+
|
488
|
+
launch("file_1_spec.rb:1", searcher: searcher)
|
489
|
+
assert_equal "cd /src/inline/gem && bundle exec rspec /src/inline/gem/spec/file_1_spec.rb:1", shell_mock.recall_exec
|
490
|
+
end
|
68
491
|
end
|
69
492
|
end
|