test_launcher 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/README.md +101 -18
  4. data/Rakefile +6 -0
  5. data/bin/test_launcher +8 -35
  6. data/lib/test_launcher.rb +22 -0
  7. data/lib/test_launcher/cli/input_parser.rb +73 -0
  8. data/lib/test_launcher/frameworks.rb +32 -0
  9. data/lib/test_launcher/frameworks/base.rb +54 -0
  10. data/lib/test_launcher/frameworks/implementation/collection.rb +27 -0
  11. data/lib/test_launcher/{tests/minitest → frameworks/implementation}/consolidator.rb +30 -32
  12. data/lib/test_launcher/frameworks/implementation/locator.rb +74 -0
  13. data/lib/test_launcher/frameworks/implementation/test_case.rb +65 -0
  14. data/lib/test_launcher/frameworks/minitest.rb +67 -0
  15. data/lib/test_launcher/frameworks/rspec.rb +50 -0
  16. data/lib/test_launcher/rubymine.rb +26 -0
  17. data/lib/test_launcher/rubymine/launcher.rb +55 -0
  18. data/lib/test_launcher/search/git.rb +64 -0
  19. data/lib/test_launcher/shell/runner.rb +19 -22
  20. data/lib/test_launcher/version.rb +1 -1
  21. data/test/install +3 -0
  22. data/test/test_helper.rb +32 -17
  23. data/test/test_launcher/fixtures/minitest/test/class_1_test.rb +17 -0
  24. data/test/test_launcher/fixtures/minitest/test/class_2_test.rb +5 -0
  25. data/test/test_launcher/fixtures/minitest/test/different_root/bin/spring +1 -0
  26. data/test/test_launcher/fixtures/minitest/test/different_root/test/different_root_test.rb +2 -0
  27. data/test/test_launcher/fixtures/rspec/spec/class_1_spec.rb +16 -0
  28. data/test/test_launcher/fixtures/rspec/spec/class_2_spec.rb +6 -0
  29. data/test/test_launcher/fixtures/rspec/spec/different_root/spec/different_root_spec.rb +2 -0
  30. data/test/test_launcher/minitest_integration_test.rb +67 -0
  31. data/test/test_launcher/rspec_integration_test.rb +67 -0
  32. data/test/test_launcher/rubymine_test.rb +48 -0
  33. data/test_launcher.gemspec +2 -3
  34. metadata +39 -44
  35. data/bin/test_runner +0 -1
  36. data/lib/test_launcher/searchers/git_searcher.rb +0 -38
  37. data/lib/test_launcher/tests/minitest/finder.rb +0 -50
  38. data/lib/test_launcher/tests/minitest/wrappers/multiple_files.rb +0 -23
  39. data/lib/test_launcher/tests/minitest/wrappers/multiple_roots.rb +0 -23
  40. data/lib/test_launcher/tests/minitest/wrappers/single_file.rb +0 -29
  41. data/lib/test_launcher/tests/minitest/wrappers/single_root.rb +0 -27
  42. data/lib/test_launcher/tests/minitest/wrappers/single_test.rb +0 -37
  43. data/lib/test_launcher/utils/path.rb +0 -32
  44. data/lib/test_launcher/utils/pluralize.rb +0 -14
  45. data/test/test_launcher/searchers/git_searcher_test.rb +0 -50
  46. data/test/test_launcher/tests/minitest/consolidator_integration_test.rb +0 -191
  47. data/test/test_launcher/tests/minitest/finder_test.rb +0 -71
@@ -1,191 +0,0 @@
1
- require "test_helper"
2
- require "test_launcher/tests/minitest/consolidator"
3
-
4
- module TestLauncher
5
- module Tests
6
- module Minitest
7
- class ConsolidatorIntegrationTest < TestCase
8
-
9
- def test_single_test_method__no_sub_dir
10
- search_results = [
11
- {
12
- file: "test/dir/file_test.rb",
13
- line: "def test_launcher",
14
- },
15
- ]
16
-
17
- consolidator = Consolidator.new(search_results, dummy_shell, false)
18
- assert_equal "cd . && ruby -I test test/dir/file_test.rb --name=/test_launcher/", consolidator.consolidate.to_command
19
- assert_notified "Found 1 test method in 1 file."
20
- end
21
-
22
- def test_single_test_method__with_sub_dir
23
- search_results = [
24
- {
25
- file: "engines/lawnmower/test/dir/file_test.rb",
26
- line: "def test_launcher",
27
- }
28
- ]
29
-
30
- consolidator = Consolidator.new(search_results, dummy_shell, false)
31
- assert_equal "cd ./engines/lawnmower && ruby -I test test/dir/file_test.rb --name=/test_launcher/", consolidator.consolidate.to_command
32
- assert_notified "Found 1 test method in 1 file."
33
- end
34
-
35
- def test_multiple_test_methods_in_same_file
36
- search_results = [
37
- {
38
- file: "test/dir/file_test.rb",
39
- line: "def test_launcher",
40
- },
41
- {
42
- file: "test/dir/file_test.rb",
43
- line: "def test_launcher_again",
44
- },
45
- {
46
- file: "test/dir/file_test.rb",
47
- line: "def test_launcher_some_more",
48
- },
49
- ]
50
-
51
- consolidator = Consolidator.new(search_results, dummy_shell, false)
52
-
53
- assert_equal "cd . && ruby -I test test/dir/file_test.rb --name=/test_launcher/", consolidator.consolidate.to_command
54
- assert_notified "Found 3 test methods in 1 file."
55
- end
56
-
57
- def test_multiple_test_methods_in_different_files__last_edited
58
- search_results = [
59
- {
60
- file: "test/dir/file_test.rb",
61
- line: "def test_launcher",
62
- },
63
- {
64
- file: "test/other_dir/different_test.rb",
65
- line: "def test_launcher",
66
- },
67
- ]
68
-
69
- consolidator = Consolidator.new(search_results, dummy_shell, false)
70
-
71
- File.expects(:mtime).with("test/dir/file_test.rb").returns(Time.new(2014, 01, 01))
72
- File.expects(:mtime).with("test/other_dir/different_test.rb").returns(Time.new(2013, 01, 01))
73
-
74
- assert_equal "cd . && ruby -I test test/dir/file_test.rb --name=/test_launcher/", consolidator.consolidate.to_command
75
- assert_notified "Found 2 test methods in 2 files."
76
- end
77
-
78
- def test_multiple_test_methods_in_different_files__run_all__same_root
79
- search_results = [
80
- {
81
- file: "test/dir/file_test.rb",
82
- line: "def test_launcher",
83
- },
84
- {
85
- file: "test/other_dir/different_test.rb",
86
- line: "def test_launcher",
87
- },
88
- ]
89
-
90
- consolidator = Consolidator.new(search_results, dummy_shell, true)
91
-
92
- assert_equal %{cd . && ruby -I test -e 'ARGV.each { |file| require(Dir.pwd + "/" + file) }' test/dir/file_test.rb test/other_dir/different_test.rb}, consolidator.consolidate.to_command
93
- assert_notified "Found 2 files."
94
- end
95
-
96
- def test_multiple_test_methods_in_different_files__run_all__different_roots
97
- search_results = [
98
- {
99
- file: "engine1/test/dir/file_test.rb",
100
- line: "def test_launcher",
101
- },
102
- {
103
- file: "engine2/root2/test/other_dir/different_test.rb",
104
- line: "def test_launcher",
105
- },
106
- ]
107
-
108
- consolidator = Consolidator.new(search_results, dummy_shell, true)
109
- expected = <<-SHELL
110
- cd ./engine1 && ruby -I test -e 'ARGV.each { |file| require(Dir.pwd + \"/\" + file) }' test/dir/file_test.rb; cd -;
111
-
112
- cd ./engine2/root2 && ruby -I test -e 'ARGV.each { |file| require(Dir.pwd + \"/\" + file) }' test/other_dir/different_test.rb
113
- SHELL
114
-
115
- assert_paragraphs_equal expected, consolidator.consolidate.to_command
116
- assert_notified "Found 2 files."
117
- end
118
-
119
- def test_one_file_found
120
- search_results = [
121
- {
122
- file: "engine1/test/dir/file_test.rb",
123
- },
124
- ]
125
-
126
- consolidator = Consolidator.new(search_results, dummy_shell, true)
127
-
128
- assert_equal "cd ./engine1 && ruby -I test test/dir/file_test.rb", consolidator.consolidate.to_command
129
- assert_notified "Found 1 file."
130
- end
131
-
132
- def test_multiple_files__last_edited
133
- search_results = [
134
- {
135
- file: "test/dir/file_test.rb",
136
- },
137
- {
138
- file: "test/other_dir/different_test.rb",
139
- },
140
- ]
141
-
142
- consolidator = Consolidator.new(search_results, dummy_shell, false)
143
-
144
- File.expects(:mtime).with("test/dir/file_test.rb").returns(Time.new(2014, 01, 01))
145
- File.expects(:mtime).with("test/other_dir/different_test.rb").returns(Time.new(2013, 01, 01))
146
-
147
- assert_equal "cd . && ruby -I test test/dir/file_test.rb", consolidator.consolidate.to_command
148
- assert_notified "Found 2 files."
149
- end
150
-
151
- def test_multiple_files__run_all__same_root
152
- search_results = [
153
- {
154
- file: "engine1/test/dir/file_test.rb",
155
- },
156
- {
157
- file: "engine1/test/other_dir/different_test.rb",
158
- },
159
- ]
160
-
161
- consolidator = Consolidator.new(search_results, dummy_shell, true)
162
- expected = %{cd ./engine1 && ruby -I test -e 'ARGV.each { |file| require(Dir.pwd + \"/\" + file) }' test/dir/file_test.rb test/other_dir/different_test.rb}
163
-
164
- assert_equal expected, consolidator.consolidate.to_command
165
- assert_notified "Found 2 files."
166
- end
167
-
168
- def test_multiple_files__run_all__different_roots
169
- search_results = [
170
- {
171
- file: "engine1/test/dir/file_test.rb",
172
- },
173
- {
174
- file: "engine2/root2/test/other_dir/different_test.rb",
175
- },
176
- ]
177
-
178
- consolidator = Consolidator.new(search_results, dummy_shell, true)
179
- expected = <<-SHELL
180
- cd ./engine1 && ruby -I test -e 'ARGV.each { |file| require(Dir.pwd + \"/\" + file) }' test/dir/file_test.rb; cd -;
181
-
182
- cd ./engine2/root2 && ruby -I test -e 'ARGV.each { |file| require(Dir.pwd + \"/\" + file) }' test/other_dir/different_test.rb
183
- SHELL
184
-
185
- assert_paragraphs_equal expected, consolidator.consolidate.to_command
186
- assert_notified "Found 2 files."
187
- end
188
- end
189
- end
190
- end
191
- end
@@ -1,71 +0,0 @@
1
- require "test_helper"
2
- require "test_launcher/tests/minitest/finder"
3
-
4
- module TestLauncher
5
- module Tests
6
- module Minitest
7
- class FinderTest < TestCase
8
-
9
- def test_find__absolute_path
10
- Dir.expects(:pwd).returns("/absolute/path/root")
11
- results = Finder.find("/absolute/path/root/test/dir/file_test.rb", "searcher_stub")
12
- assert_equal [{file: "test/dir/file_test.rb"}], results
13
- end
14
-
15
- def test_find__found_by_name
16
- expected = [{file: "test/file.rb", line: "def test_name"}]
17
- searcher_mock = mock do
18
- stubs(:grep).with("^\s*def .*test_name.*", file_pattern: "*_test.rb").returns(expected)
19
- end
20
-
21
- assert_equal expected, Finder.find("test_name", searcher_mock)
22
- end
23
-
24
- def test_find__found_by_file_name
25
- searcher_mock = mock do
26
- stubs(:grep).returns([])
27
- stubs(:find_files).with("file_query").returns([
28
- "dir/test/non_test_file_query.rb",
29
- "dir/thing/file_query_test.rb",
30
- "other_dir/other_thing/other_file_query_test.rb",
31
- ])
32
- end
33
-
34
- expected = [
35
- { file: "dir/thing/file_query_test.rb" },
36
- { file: "other_dir/other_thing/other_file_query_test.rb" },
37
- ]
38
-
39
- assert_equal expected, Finder.find("file_query", searcher_mock)
40
- end
41
-
42
- def test_find__found_by_full_regex
43
- searcher_mock = mock do
44
- stubs(:grep).returns([])
45
- stubs(:find_files).returns([])
46
-
47
- stubs(:grep).with("full_regex_search", file_pattern: "*_test.rb").returns([
48
- { file: "path/to/file_test.rb", line: "random_match"},
49
- { file: "path/to/other_file_test.rb", line: "random_match_2"}
50
- ])
51
- end
52
-
53
- expected = [
54
- {file: "path/to/file_test.rb"},
55
- {file: "path/to/other_file_test.rb"}
56
- ]
57
- assert_equal expected, Finder.find("full_regex_search", searcher_mock)
58
- end
59
-
60
- def test_find__nothing_found
61
- searcher_mock = mock do
62
- stubs(:grep).returns([])
63
- stubs(:find_files).returns([])
64
- end
65
-
66
- assert_equal [], Finder.find("query", searcher_mock)
67
- end
68
- end
69
- end
70
- end
71
- end