test_launcher 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -0
  3. data/bin/test_launcher +2 -5
  4. data/lib/test_launcher/cli/input_parser.rb +37 -12
  5. data/lib/test_launcher/cli/query.rb +30 -0
  6. data/lib/test_launcher/cli/request.rb +61 -0
  7. data/lib/test_launcher/cli.rb +44 -0
  8. data/lib/test_launcher/frameworks/base.rb +26 -7
  9. data/lib/test_launcher/frameworks/elixir.rb +84 -0
  10. data/lib/test_launcher/frameworks/implementation/test_case.rb +4 -7
  11. data/lib/test_launcher/frameworks/minitest.rb +80 -23
  12. data/lib/test_launcher/frameworks/rspec.rb +38 -13
  13. data/lib/test_launcher/queries.rb +346 -0
  14. data/lib/test_launcher/rubymine/launcher.rb +1 -12
  15. data/lib/test_launcher/rubymine/request.rb +15 -0
  16. data/lib/test_launcher/rubymine.rb +20 -13
  17. data/lib/test_launcher/search/ag.rb +96 -0
  18. data/lib/test_launcher/search/git.rb +6 -2
  19. data/lib/test_launcher/search.rb +18 -0
  20. data/lib/test_launcher/shell/runner.rb +2 -1
  21. data/lib/test_launcher/version.rb +1 -1
  22. data/lib/test_launcher.rb +0 -26
  23. data/test/test_helper.rb +2 -1
  24. data/test/test_helpers/integration_helper.rb +40 -0
  25. data/test/test_helpers/mock.rb +59 -0
  26. data/test/test_helpers/mock_searcher.rb +1 -0
  27. data/test/test_helpers/mocks/searcher_mock.rb +82 -0
  28. data/test/test_helpers/mocks.rb +76 -0
  29. data/test/test_launcher/cli/input_parser_test.rb +72 -0
  30. data/test/test_launcher/frameworks/minitest/runner_test.rb +72 -0
  31. data/test/test_launcher/frameworks/minitest/searcher_test.rb +109 -0
  32. data/test/test_launcher/frameworks/rspec/runner_test.rb +76 -0
  33. data/test/test_launcher/frameworks/rspec/searcher_test.rb +54 -0
  34. data/test/test_launcher/minitest_integration_test.rb +31 -40
  35. data/test/test_launcher/queries/example_name_query_test.rb +217 -0
  36. data/test/test_launcher/queries/full_regex_query_test.rb +153 -0
  37. data/test/test_launcher/queries/generic_query_test.rb +23 -0
  38. data/test/test_launcher/queries/line_number_query_test.rb +107 -0
  39. data/test/test_launcher/queries/multi_term_query_test.rb +138 -0
  40. data/test/test_launcher/queries/path_query_test.rb +192 -0
  41. data/test/test_launcher/queries/search_query_test.rb +54 -0
  42. data/test/test_launcher/queries/single_term_query_test.rb +36 -0
  43. data/test/test_launcher/queries/specified_name_query_test.rb +112 -0
  44. data/test/test_launcher/rspec_integration_test.rb +27 -41
  45. data/test/test_launcher/search/git_test.rb +2 -0
  46. metadata +49 -10
  47. data/lib/test_launcher/frameworks/implementation/collection.rb +0 -36
  48. data/lib/test_launcher/frameworks/implementation/consolidator.rb +0 -83
  49. data/lib/test_launcher/frameworks/implementation/locator.rb +0 -118
  50. data/lib/test_launcher/frameworks.rb +0 -20
  51. data/lib/test_launcher/request.rb +0 -36
  52. data/test/test_launcher/frameworks/implementation/locator_test.rb +0 -166
@@ -0,0 +1,138 @@
1
+ require "test_helper"
2
+ require "test_helpers/mocks"
3
+ require "test_launcher/queries"
4
+
5
+ module TestLauncher
6
+ module Queries
7
+ class MultiTermQueryTest < 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 = MultiTermQuery.new(request, default_command_finder).command
73
+
74
+ assert_equal nil, command
75
+ end
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
+ def test_command__finds_files_for_1_of_2_terms
90
+ request = create_mock_request(
91
+ search_string: "file_1 not_found",
92
+ shell: default_shell,
93
+ runner: default_runner,
94
+ searcher: searcher
95
+ )
96
+ command = MultiTermQuery.new(request, default_command_finder).command
97
+
98
+ assert_equal nil, command
99
+ end
100
+
101
+ def test_command__finds_files_for_1_of_2_terms__warns
102
+ request = create_mock_request(
103
+ search_string: "file_1 not_found",
104
+ shell: default_shell,
105
+ searcher: searcher
106
+ )
107
+ command = MultiTermQuery.new(request, default_command_finder).command
108
+
109
+ assert_equal 1, default_shell.recall(:warn).size
110
+ end
111
+
112
+ def test_command__finds_files_for_2_of_2_terms
113
+ request = create_mock_request(
114
+ search_string: "file_1 file_2",
115
+ shell: default_shell,
116
+ runner: default_runner,
117
+ searcher: searcher,
118
+ )
119
+ command = MultiTermQuery.new(request, default_command_finder).command
120
+
121
+ assert_equal [[[file_1_test_case, file_2_test_case]]], default_runner.recall(:multiple_files)
122
+ assert_equal "multiple_files_return", command
123
+ end
124
+
125
+ def test_command__finds_files_for_2_of_2_terms__extra_files_found
126
+ request = create_mock_request(
127
+ search_string: "file_1 files",
128
+ shell: default_shell,
129
+ runner: default_runner,
130
+ searcher: searcher,
131
+ )
132
+ command = MultiTermQuery.new(request, default_command_finder).command
133
+ assert_equal [[[file_1_test_case, file_3_test_case, file_4_test_case]]], default_runner.recall(:multiple_files)
134
+ assert_equal "multiple_files_return", command
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,192 @@
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
@@ -0,0 +1,54 @@
1
+ require "test_helper"
2
+ require "test_helpers/mocks"
3
+ require "test_launcher/queries"
4
+
5
+ module TestLauncher
6
+ module Queries
7
+ class SearchQueryTest < TestCase
8
+ include DefaultMocks
9
+
10
+ def test__multi_search_term__hits
11
+ command_finder = Mock.new(Queries::CommandFinder, multi_search_term: :multi_search_term)
12
+ request = MockRequest.new(search_string: "a b")
13
+
14
+ assert_equal :multi_search_term, SearchQuery.new(request, command_finder).command
15
+ end
16
+
17
+ def test__multi_search_term__misses
18
+ command_finder = Mock.new(Queries::CommandFinder, multi_search_term: nil, single_search_term: :single_search_term)
19
+ request = MockRequest.new(search_string: "a b")
20
+
21
+ assert_equal :single_search_term, SearchQuery.new(request, command_finder).command
22
+ end
23
+
24
+ def test__line_number__hits
25
+ command_finder = Mock.new(Queries::CommandFinder, line_number: :line_number)
26
+ request = MockRequest.new(search_string: "a:1")
27
+
28
+ assert_equal :line_number, SearchQuery.new(request, command_finder).command
29
+ end
30
+
31
+ def test__line_number__misses
32
+ command_finder = Mock.new(Queries::CommandFinder, line_number: nil, single_search_term: :single_search_term)
33
+ request = MockRequest.new(search_string: "a:1")
34
+
35
+ assert_equal :single_search_term, SearchQuery.new(request, command_finder).command
36
+ end
37
+
38
+ def test__single_search_term
39
+ command_finder = Mock.new(Queries::CommandFinder, single_search_term: :single_search_term)
40
+ request = MockRequest.new(search_string: "a")
41
+
42
+ assert_equal :single_search_term, SearchQuery.new(request, command_finder).command
43
+ end
44
+
45
+ def test__none
46
+ command_finder = Mock.new(Queries::CommandFinder, single_search_term: nil)
47
+ request = MockRequest.new(search_string: "a")
48
+
49
+ assert_equal nil, SearchQuery.new(request, command_finder).command
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,36 @@
1
+ require "test_helper"
2
+ require "test_helpers/mocks"
3
+ require "test_launcher/queries"
4
+
5
+ module TestLauncher
6
+ module Queries
7
+ class SingleTermQueryTest < TestCase
8
+ include DefaultMocks
9
+
10
+ def test__by_path
11
+ command_finder = Mock.new(Queries::CommandFinder, by_path: :by_path)
12
+
13
+ assert_equal :by_path, SingleTermQuery.new(MockRequest.new, command_finder).command
14
+ end
15
+
16
+ def test__example_name
17
+ command_finder = Mock.new(Queries::CommandFinder, by_path: nil, example_name: :example_name)
18
+
19
+ assert_equal :example_name, SingleTermQuery.new(MockRequest.new, command_finder).command
20
+ end
21
+
22
+ def test__from_full_regex
23
+ command_finder = Mock.new(Queries::CommandFinder, by_path: nil, example_name: nil, from_full_regex: :from_full_regex)
24
+
25
+ assert_equal :from_full_regex, SingleTermQuery.new(MockRequest.new, command_finder).command
26
+ end
27
+
28
+ def test__none
29
+ command_finder = Mock.new(Queries::CommandFinder, by_path: nil, example_name: nil, from_full_regex: nil)
30
+
31
+ assert_equal nil, SingleTermQuery.new(MockRequest.new, command_finder).command
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,112 @@
1
+ require "test_helper"
2
+ require "test_helpers/mocks"
3
+ require "test_launcher/queries"
4
+
5
+ module TestLauncher
6
+ module Queries
7
+ class SpecifiedNameQueryTest < 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 "multiple_matches"
17
+ ["file_1", "file_2"]
18
+ when "exact_match"
19
+ ["matched_file.rb"]
20
+ else
21
+ raise "can't find #{search_string}"
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ def test_command__file_not_found__returns_no_command
28
+ request = MockRequest.new(
29
+ search_string: "not_found",
30
+ shell: default_shell,
31
+ searcher: searcher
32
+ )
33
+ query = SpecifiedNameQuery.new(request, MockCommandFinder.new)
34
+
35
+ assert_equal nil, query.command
36
+ end
37
+
38
+ def test_command__file_not_found__warns
39
+ request = MockRequest.new(
40
+ search_string: "not_found",
41
+ shell: default_shell,
42
+ searcher: searcher
43
+ )
44
+ SpecifiedNameQuery.new(request, MockCommandFinder.new).command
45
+
46
+ assert_equal 1, default_shell.recall(:warn).size
47
+ end
48
+
49
+ def test_command__multiple_files_found
50
+ request = MockRequest.new(
51
+ search_string: "multiple_matches",
52
+ shell: default_shell,
53
+ searcher: searcher
54
+ )
55
+ query = SpecifiedNameQuery.new(request, MockCommandFinder.new)
56
+
57
+ assert_equal nil, query.command
58
+ end
59
+
60
+ def test_command__multiple_files_found__warns
61
+ request = MockRequest.new(
62
+ search_string: "multiple_matches",
63
+ shell: default_shell,
64
+ searcher: searcher
65
+ )
66
+ SpecifiedNameQuery.new(request, MockCommandFinder.new).command
67
+
68
+ assert_equal 1, default_shell.recall(:warn).size
69
+ end
70
+
71
+ def test_command__exact_match__command_is_single_example
72
+ request = MockRequest.new(
73
+ search_string: "exact_match",
74
+ example_name: "example_name",
75
+ test_case: default_test_case,
76
+ shell: default_shell,
77
+ runner: default_runner,
78
+ searcher: searcher
79
+ ) do |m|
80
+ m.impl(:test_case) { default_test_case }
81
+ end # TODO: hack while implementing new searcher mocking
82
+ command = SpecifiedNameQuery.new(request, MockCommandFinder.new).command
83
+
84
+ expected_runner_args = [
85
+ default_test_case,
86
+ ]
87
+ assert_includes default_runner.recall(:single_example), expected_runner_args
88
+ assert_equal "single_example_return", command
89
+ end
90
+
91
+ def test_command__exact_match__creates_example_test_case
92
+ request = MockRequest.new(
93
+ search_string: "exact_match",
94
+ example_name: "example_name",
95
+ test_case: default_test_case,
96
+ shell: default_shell,
97
+ runner: default_runner,
98
+ searcher: searcher
99
+ )
100
+ command = SpecifiedNameQuery.new(request, MockCommandFinder.new).command
101
+
102
+ expected_test_case_args = [
103
+ file: "matched_file.rb",
104
+ example: "example_name",
105
+ request: request
106
+ ]
107
+
108
+ assert_includes request.recall(:test_case), expected_test_case_args
109
+ end
110
+ end
111
+ end
112
+ end
@@ -1,83 +1,69 @@
1
1
  require "test_helper"
2
- require "test_launcher/request"
2
+ require "test_helpers/integration_helper"
3
3
 
4
4
  module TestLauncher
5
5
  class RspecIntegrationTest < TestCase
6
+ include IntegrationHelper
7
+
6
8
  def test__single_method
7
- launch("file_name_1 example_name_""1")
8
- assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} --example file_name_1\\ example_name_1", Shell::Runner.recall_exec
9
+ launch("file_name_1 example_name_""1", framework: "rspec")
10
+ assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} --example file_name_1\\ example_name_1", shell_mock.recall_exec
9
11
  end
10
12
 
11
13
  def test__single_context
12
- launch("file_name_1 con""text_1")
13
- assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} --example file_name_1\\ context_1", Shell::Runner.recall_exec
14
+ launch("file_name_1 con""text_1", framework: "rspec")
15
+ assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} --example file_name_1\\ context_1", shell_mock.recall_exec
14
16
  end
15
17
 
16
18
  def test__single_describe
17
- launch("Root1DummyTes""tClass1")
18
- assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} --example Root1DummyTes""tClass1", Shell::Runner.recall_exec
19
+ launch("Root1DummyTes""tClass1", framework: "rspec")
20
+ assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} --example Root1DummyTes""tClass1", shell_mock.recall_exec
19
21
  end
20
22
 
21
23
  def test__multiple_methods__same_file
22
- launch("file_name_1")
23
- assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} --example file_name_1", Shell::Runner.recall_exec
24
+ launch("file_name_1", framework: "rspec")
25
+ assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} --example file_name_1", shell_mock.recall_exec
24
26
  end
25
27
 
26
28
  def test__multiple_methods__different_files
27
- launch("multiple_files same_example")
28
- assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")} --example multiple_files\\ same_example", Shell::Runner.recall_exec
29
+ launch("multiple_files same_example", framework: "rspec")
30
+ assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")} --example multiple_files\\ same_example", shell_mock.recall_exec
29
31
  end
30
32
 
31
33
  def test__single_file
32
- launch("class_1_spec")
33
- assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")}", Shell::Runner.recall_exec
34
+ launch("class_1_spec", framework: "rspec")
35
+ assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")}", shell_mock.recall_exec
34
36
  end
35
37
 
36
38
  def test__multiple_files__found
37
- launch("Root1") # don't trigger the find in *this* file
38
- assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")} --example Roo""t1", Shell::Runner.recall_exec
39
+ launch("Root1", framework: "rspec") # don't trigger the find in *this* file
40
+ assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")} --example Roo""t1", shell_mock.recall_exec
39
41
  end
40
42
 
41
43
  def test__multiple_files__found__all
42
- launch("Root1""DummyTest""Class", run_all: true) # don't trigger the find in *this* file
43
- assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")}", Shell::Runner.recall_exec
44
+ launch("Root1""DummyTest""Class", run_all: true, framework: "rspec") # don't trigger the find in *this* file
45
+ assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")}", shell_mock.recall_exec
44
46
  end
45
47
 
46
48
  def test__multiple_file_paths
47
- launch("class_1_spec.rb class_2_spec.rb") # don't trigger the find in *this* file
48
- assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")}", Shell::Runner.recall_exec
49
+ launch("class_1_spec.rb class_2_spec.rb", framework: "rspec") # don't trigger the find in *this* file
50
+ assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")}", shell_mock.recall_exec
49
51
  end
50
52
 
51
53
  def test__multiple_files__different_roots__all
52
- launch("DummyTest""Class", run_all: true) # don't trigger the find in *this* file
54
+ launch("DummyTest""Class", run_all: true, framework: "rspec") # don't trigger the find in *this* file
53
55
  expected = "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_1_spec.rb")} #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")}; cd -;\n\ncd #{system_path("test/test_launcher/fixtures/rspec/spec/different_root")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/different_root/spec/different_root_spec.rb")}"
54
- assert_equal expected, Shell::Runner.recall_exec
56
+ assert_equal expected, shell_mock.recall_exec
55
57
  end
56
58
 
57
59
  def test__regex
58
- launch("a_test_that_u""ses") # don't trigger the find in *this* file
59
- assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")}", Shell::Runner.recall_exec
60
+ launch("a_test_that_u""ses", framework: "rspec") # don't trigger the find in *this* file
61
+ assert_equal "cd #{system_path("test/test_launcher/fixtures/rspec")} && rspec #{system_path("test/test_launcher/fixtures/rspec/spec/class_2_spec.rb")}", shell_mock.recall_exec
60
62
  end
61
63
 
62
64
  def test__not_found
63
- launch("not_found""thing")
64
- assert_equal nil, Shell::Runner.recall_exec
65
- end
66
-
67
- private
68
-
69
- def system_path(relative_dir)
70
- File.join(Dir.pwd, relative_dir)
71
- end
72
-
73
- def launch(query, run_all: false)
74
- request = Request.new(
75
- query: query,
76
- run_all: run_all,
77
- framework: "rspec"
78
- )
79
-
80
- TestLauncher.launch(request)
65
+ launch("not_found""thing", framework: "rspec")
66
+ assert_equal nil, shell_mock.recall_exec
81
67
  end
82
68
  end
83
69
  end
@@ -1,9 +1,11 @@
1
1
  require "test_helper"
2
2
  require "test_launcher/search/git"
3
+ require "test_helpers/mocks"
3
4
 
4
5
  module TestLauncher
5
6
  module Search
6
7
  class GitTest < TestCase
8
+ include DefaultMocks
7
9
 
8
10
  def setup
9
11
  super