test_run 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/bin/test_runner +7 -6
- data/lib/test_run.rb +0 -1
- data/lib/test_run/tests/minitest/consolidator.rb +54 -11
- data/lib/test_run/tests/minitest/finder.rb +5 -5
- data/lib/test_run/tests/minitest/wrappers/multiple_roots.rb +1 -6
- data/lib/test_run/tests/minitest/wrappers/single_file.rb +0 -4
- data/lib/test_run/tests/minitest/wrappers/single_root.rb +0 -6
- data/lib/test_run/tests/minitest/wrappers/single_test.rb +0 -5
- data/lib/test_run/utils/pluralize.rb +14 -0
- data/lib/test_run/version.rb +1 -1
- data/test/test_helper.rb +45 -0
- data/test/test_run/searchers/git_searcher_test.rb +50 -0
- data/test/test_run/tests/minitest/consolidator_integration_test.rb +191 -0
- data/test/test_run/tests/minitest/finder_test.rb +71 -0
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dfb581e79ad2ee6189a16d9142b5b2f9599bea8
|
4
|
+
data.tar.gz: b7aefde679ecea6e53ccdf15ce30c997cb4c4b1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e9ab26f96fb3849ae28d3cbcd96ce085102f9587d3d75ca5761eba1748fa6530172ea726b0e61df341d36af3dfdf8e9622955fc5d02db6b97eb016c811fafb5
|
7
|
+
data.tar.gz: 1e8d2bbed3a5a87708364b7123e35a50dc7979425a21d0fc7d5552492ee829b91b43e34d25c4a20856ae40af5afbb496b34f68447d07d03e1be0cefaaf7f4a80
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/bin/test_runner
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "thor"
|
4
|
+
require "test_run/searchers/git_searcher"
|
4
5
|
require "test_run/tests/minitest/finder"
|
5
6
|
require "test_run/tests/minitest/consolidator"
|
6
7
|
require "test_run/shell/runner"
|
@@ -10,10 +11,11 @@ class CLI < Thor
|
|
10
11
|
desc "find", <<-DESC
|
11
12
|
Find tests and run them. By trying to match an individual test or the name of a test file(s).
|
12
13
|
DESC
|
14
|
+
option :all, type: :boolean, desc: %{Run all tests found!}, default: false
|
13
15
|
|
14
16
|
def find(input)
|
15
17
|
if input == '--help'
|
16
|
-
|
18
|
+
`test_runner --help find`
|
17
19
|
exit
|
18
20
|
end
|
19
21
|
|
@@ -23,13 +25,12 @@ class CLI < Thor
|
|
23
25
|
|
24
26
|
)
|
25
27
|
|
26
|
-
|
28
|
+
searcher = TestRun::Searchers::GitSearcher.new(shell)
|
29
|
+
search_results = TestRun::Tests::Minitest::Finder.find(input, searcher)
|
27
30
|
|
28
|
-
|
31
|
+
test_wrapper = TestRun::Tests::Minitest::Consolidator.consolidate(search_results, shell, options[:all])
|
29
32
|
|
30
|
-
|
31
|
-
shell.exec test_wrapper.to_command
|
32
|
-
end
|
33
|
+
shell.exec test_wrapper.to_command
|
33
34
|
end
|
34
35
|
|
35
36
|
default_task :find
|
data/lib/test_run.rb
CHANGED
@@ -3,39 +3,82 @@ require "test_run/utils/path"
|
|
3
3
|
require "test_run/tests/minitest/wrappers/single_test"
|
4
4
|
require "test_run/tests/minitest/wrappers/single_file"
|
5
5
|
require "test_run/tests/minitest/wrappers/multiple_files"
|
6
|
+
require "test_run/utils/pluralize"
|
6
7
|
|
7
8
|
module TestRun
|
8
9
|
module Tests
|
9
10
|
module Minitest
|
10
|
-
class Consolidator < Struct.new(:
|
11
|
+
class Consolidator < Struct.new(:search_results, :shell, :run_all)
|
12
|
+
include Utils::Pluralize
|
11
13
|
|
12
14
|
def self.consolidate(*args)
|
13
15
|
new(*args).consolidate
|
14
16
|
end
|
15
17
|
|
16
18
|
def consolidate
|
17
|
-
if
|
18
|
-
|
19
|
+
if search_results.empty?
|
20
|
+
shell.warn "Could not find any tests."
|
19
21
|
exit
|
20
22
|
end
|
21
23
|
|
22
|
-
if one_result?
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
if methods_found? && one_result?
|
25
|
+
shell.notify "Found #{methods_count_phrase} in #{file_count_phrase}."
|
26
|
+
Wrappers::SingleTest.new(search_results.first)
|
27
|
+
elsif methods_found? && same_file?
|
28
|
+
shell.notify "Multiple test methods match in 1 file."
|
29
|
+
Wrappers::SingleFile.new(search_results.first[:file])
|
30
|
+
elsif methods_found? && run_last_edited?
|
31
|
+
shell.notify "Found #{methods_count_phrase} in #{file_count_phrase}."
|
32
|
+
shell.notify "Running most recently edited. Run with '--all' to run all the tests."
|
33
|
+
Wrappers::SingleTest.new(last_edited)
|
34
|
+
elsif files_found? && same_file?
|
35
|
+
shell.notify "Found #{file_count_phrase}."
|
36
|
+
Wrappers::SingleFile.new(search_results.first[:file])
|
37
|
+
elsif files_found? && run_last_edited?
|
38
|
+
shell.notify "Found #{file_count_phrase}."
|
39
|
+
shell.notify "Running most recently edited. Run with '--all' to run all the tests."
|
40
|
+
Wrappers::SingleFile.new(last_edited[:file])
|
26
41
|
else
|
27
|
-
|
42
|
+
shell.notify "Found #{file_count_phrase}."
|
43
|
+
Wrappers::MultipleFiles.wrap(search_results.map {|r| r[:file] }, shell)
|
28
44
|
end
|
29
45
|
end
|
30
46
|
|
31
|
-
def
|
32
|
-
|
47
|
+
def same_file?
|
48
|
+
file_count == 1
|
33
49
|
end
|
34
50
|
|
35
51
|
def one_result?
|
36
|
-
|
52
|
+
same_file? && search_results.first[:line]
|
37
53
|
end
|
38
54
|
|
55
|
+
def methods_found?
|
56
|
+
!! search_results.first[:line]
|
57
|
+
end
|
58
|
+
|
59
|
+
def files_found?
|
60
|
+
! methods_found?
|
61
|
+
end
|
62
|
+
|
63
|
+
def run_last_edited?
|
64
|
+
! run_all
|
65
|
+
end
|
66
|
+
|
67
|
+
def last_edited
|
68
|
+
search_results.sort_by {|r| File.mtime(r[:file])}.last
|
69
|
+
end
|
70
|
+
|
71
|
+
def file_count
|
72
|
+
search_results.group_by {|f| f[:file]}.size
|
73
|
+
end
|
74
|
+
|
75
|
+
def methods_count_phrase
|
76
|
+
pluralize(search_results.size, "test method")
|
77
|
+
end
|
78
|
+
|
79
|
+
def file_count_phrase
|
80
|
+
pluralize(file_count, "file")
|
81
|
+
end
|
39
82
|
end
|
40
83
|
end
|
41
84
|
end
|
@@ -3,11 +3,10 @@ require "test_run/searchers/git_searcher"
|
|
3
3
|
module TestRun
|
4
4
|
module Tests
|
5
5
|
module Minitest
|
6
|
-
class Finder < Struct.new(:query, :
|
6
|
+
class Finder < Struct.new(:query, :searcher)
|
7
7
|
|
8
|
-
def self.find(query,
|
9
|
-
|
10
|
-
new(query, shell, searcher, options).find
|
8
|
+
def self.find(query, searcher)
|
9
|
+
new(query, searcher).find
|
11
10
|
end
|
12
11
|
|
13
12
|
def find
|
@@ -25,7 +24,8 @@ module TestRun
|
|
25
24
|
private
|
26
25
|
|
27
26
|
def tests_found_by_absolute_path
|
28
|
-
|
27
|
+
relative_file_path = query.sub(Dir.pwd, '').sub(/^\//, '')
|
28
|
+
[ {file: relative_file_path} ]
|
29
29
|
end
|
30
30
|
|
31
31
|
def tests_found_by_name
|
@@ -14,13 +14,8 @@ module TestRun
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def to_command
|
17
|
-
roots.map(&:to_command).join("; cd
|
17
|
+
roots.map(&:to_command).join("; cd -;\n\n")
|
18
18
|
end
|
19
|
-
|
20
|
-
def should_run?
|
21
|
-
shell.confirm?("Found #{roots.inject(0) {|sum, root| sum + root.files.size }} test files in #{roots.size} apps/engines. Run them all?")
|
22
|
-
end
|
23
|
-
|
24
19
|
end
|
25
20
|
end
|
26
21
|
end
|
@@ -13,11 +13,6 @@ module TestRun
|
|
13
13
|
@files = files.map {|f| f.is_a?(SingleFile) ? f : SingleFile.new(f)}
|
14
14
|
end
|
15
15
|
|
16
|
-
def should_run?
|
17
|
-
# keep working here!
|
18
|
-
true
|
19
|
-
end
|
20
|
-
|
21
16
|
def to_command
|
22
17
|
%{cd #{app_root} && ruby -I test -e 'ARGV.each { |file| require(Dir.pwd + "/" + file) }' #{files.map(&:relative_test_path).join(" ")}}
|
23
18
|
end
|
@@ -25,7 +20,6 @@ module TestRun
|
|
25
20
|
def app_root
|
26
21
|
files.first.app_root
|
27
22
|
end
|
28
|
-
|
29
23
|
end
|
30
24
|
end
|
31
25
|
end
|
data/lib/test_run/version.rb
CHANGED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.split(File.dirname(__FILE__))[0], 'lib'))
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "mocha/mini_test"
|
4
|
+
|
5
|
+
class TestCase < Minitest::Test
|
6
|
+
class DummyShell
|
7
|
+
|
8
|
+
def method_missing(method, *args)
|
9
|
+
instance_variable_set(:"@#{method}", [args])
|
10
|
+
|
11
|
+
self.class.send(:define_method, method) do |*a|
|
12
|
+
if ! instance_variable_get(:"@#{method}")
|
13
|
+
instance_variable_set(:"@#{method}", [a])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def recall(method)
|
19
|
+
instance_variable_get(:"@#{method}")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def assert_notified(string)
|
24
|
+
unless dummy_shell.recall(:notify).flatten.include?(string)
|
25
|
+
flunk <<-FLUNK
|
26
|
+
could not find: "#{string}"
|
27
|
+
shell.notify called with:
|
28
|
+
#{dummy_shell.recall(:notify)}
|
29
|
+
FLUNK
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def assert_paragraphs_equal(expected, actual)
|
34
|
+
expecteds = expected.split("\n").map {|l| l.to_s.strip}
|
35
|
+
actuals = actual.split("\n").map {|l| l.to_s.strip}
|
36
|
+
|
37
|
+
assert_equal expecteds, actuals
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def dummy_shell
|
43
|
+
@dummy_shell ||= DummyShell.new
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "test_run/searchers/git_searcher"
|
3
|
+
|
4
|
+
module TestRun
|
5
|
+
module Searchers
|
6
|
+
class MockShell
|
7
|
+
def run(cmd)
|
8
|
+
if cmd == "git ls-files '*file_pattern*'"
|
9
|
+
[
|
10
|
+
"file/path/one.rb",
|
11
|
+
"another_file/path/two.rb",
|
12
|
+
]
|
13
|
+
elsif cmd == "git grep --untracked 'regex' -- 'file_pattern'"
|
14
|
+
[
|
15
|
+
"file/path/one.rb: some_lines(of_code)",
|
16
|
+
"another_file/path/two.rb: Class::Thing::Stuff.new",
|
17
|
+
]
|
18
|
+
else
|
19
|
+
raise ArgumentError.new("unmocked command")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class GitSearcherTest < TestCase
|
25
|
+
|
26
|
+
def test_find_files
|
27
|
+
searcher = GitSearcher.new(MockShell.new)
|
28
|
+
|
29
|
+
assert_equal ["file/path/one.rb", "another_file/path/two.rb"], searcher.find_files("file_pattern")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_grep
|
33
|
+
searcher = GitSearcher.new(MockShell.new)
|
34
|
+
|
35
|
+
expected = [
|
36
|
+
{
|
37
|
+
file: "file/path/one.rb",
|
38
|
+
line: "some_lines(of_code)",
|
39
|
+
},
|
40
|
+
{
|
41
|
+
file: "another_file/path/two.rb",
|
42
|
+
line: "Class::Thing::Stuff.new",
|
43
|
+
}
|
44
|
+
]
|
45
|
+
|
46
|
+
assert_equal expected, searcher.grep("regex", file_pattern: "file_pattern")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "test_run/tests/minitest/consolidator"
|
3
|
+
|
4
|
+
module TestRun
|
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_run",
|
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_run/", 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_run",
|
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_run/", 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_run",
|
40
|
+
},
|
41
|
+
{
|
42
|
+
file: "test/dir/file_test.rb",
|
43
|
+
line: "def test_run_again",
|
44
|
+
},
|
45
|
+
{
|
46
|
+
file: "test/dir/file_test.rb",
|
47
|
+
line: "def test_run_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_run/", 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_run",
|
62
|
+
},
|
63
|
+
{
|
64
|
+
file: "test/other_dir/different_test.rb",
|
65
|
+
line: "def test_run",
|
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_run/", 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_run",
|
83
|
+
},
|
84
|
+
{
|
85
|
+
file: "test/other_dir/different_test.rb",
|
86
|
+
line: "def test_run",
|
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_run",
|
101
|
+
},
|
102
|
+
{
|
103
|
+
file: "engine2/root2/test/other_dir/different_test.rb",
|
104
|
+
line: "def test_run",
|
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
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "test_run/tests/minitest/finder"
|
3
|
+
|
4
|
+
module TestRun
|
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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_run
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Kinnecom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -64,7 +64,12 @@ files:
|
|
64
64
|
- lib/test_run/tests/minitest/wrappers/single_root.rb
|
65
65
|
- lib/test_run/tests/minitest/wrappers/single_test.rb
|
66
66
|
- lib/test_run/utils/path.rb
|
67
|
+
- lib/test_run/utils/pluralize.rb
|
67
68
|
- lib/test_run/version.rb
|
69
|
+
- test/test_helper.rb
|
70
|
+
- test/test_run/searchers/git_searcher_test.rb
|
71
|
+
- test/test_run/tests/minitest/consolidator_integration_test.rb
|
72
|
+
- test/test_run/tests/minitest/finder_test.rb
|
68
73
|
- test_run-0.0.1.gem
|
69
74
|
- test_run.gemspec
|
70
75
|
homepage: ''
|
@@ -91,4 +96,8 @@ rubygems_version: 2.2.2
|
|
91
96
|
signing_key:
|
92
97
|
specification_version: 4
|
93
98
|
summary: Easily run tests
|
94
|
-
test_files:
|
99
|
+
test_files:
|
100
|
+
- test/test_helper.rb
|
101
|
+
- test/test_run/searchers/git_searcher_test.rb
|
102
|
+
- test/test_run/tests/minitest/consolidator_integration_test.rb
|
103
|
+
- test/test_run/tests/minitest/finder_test.rb
|