guard-minitest 0.4.0 → 0.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -2
- data/lib/guard/minitest.rb +3 -2
- data/lib/guard/minitest/inspector.rb +56 -32
- data/lib/guard/minitest/runner.rb +28 -5
- data/lib/guard/minitest/runners/version_1_runner.rb +1 -1
- data/lib/guard/minitest/runners/version_2_runner.rb +1 -1
- data/lib/guard/minitest/templates/Guardfile +6 -2
- data/lib/guard/minitest/version.rb +1 -1
- metadata +59 -64
data/README.rdoc
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
= Guard::Minitest
|
2
2
|
|
3
|
+
{<img src="https://secure.travis-ci.org/guard/guard-minitest.png" />}[http://travis-ci.org/guard/guard-minitest]
|
4
|
+
|
3
5
|
Minitest guard allows to automatically & intelligently launch tests with
|
4
6
|
{minitest framework}[http://github.com/seattlerb/minitest] when files are modified.
|
5
7
|
|
@@ -35,7 +37,7 @@ Please read {guard doc}[http://github.com/guard/guard#readme] for more info abou
|
|
35
37
|
|
36
38
|
guard 'minitest' do
|
37
39
|
watch(%r|^test/test_(.*)\.rb|)
|
38
|
-
watch(%r
|
40
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
39
41
|
watch(%r|^test/test_helper\.rb|) { "test" }
|
40
42
|
end
|
41
43
|
|
@@ -43,7 +45,7 @@ Please read {guard doc}[http://github.com/guard/guard#readme] for more info abou
|
|
43
45
|
|
44
46
|
guard 'minitest' do
|
45
47
|
watch(%r|^spec/(.*)_spec\.rb|)
|
46
|
-
watch(%r
|
48
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
47
49
|
watch(%r|^spec/spec_helper\.rb|) { "spec" }
|
48
50
|
end
|
49
51
|
|
@@ -61,6 +63,12 @@ You can set minitest verbose mode with:
|
|
61
63
|
...
|
62
64
|
end
|
63
65
|
|
66
|
+
You can change the default location and pattern of minitest files:
|
67
|
+
|
68
|
+
guard 'minitest', test_folders: 'test/unit', test_file_patterns: '*_test.rb' do
|
69
|
+
...
|
70
|
+
end
|
71
|
+
|
64
72
|
You can disable desktop notification with:
|
65
73
|
|
66
74
|
guard 'minitest', :notify => false do
|
data/lib/guard/minitest.rb
CHANGED
@@ -12,6 +12,7 @@ module Guard
|
|
12
12
|
super
|
13
13
|
|
14
14
|
@runner ||= Runner.new(options)
|
15
|
+
@inspector= Inspector.new(@runner.test_folders, @runner.test_file_patterns)
|
15
16
|
end
|
16
17
|
|
17
18
|
def start
|
@@ -27,13 +28,13 @@ module Guard
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def run_all
|
30
|
-
paths =
|
31
|
+
paths = @inspector.clean_all
|
31
32
|
return @runner.run(paths, :message => 'Running all tests') unless paths.empty?
|
32
33
|
true
|
33
34
|
end
|
34
35
|
|
35
36
|
def run_on_change(paths = [])
|
36
|
-
paths =
|
37
|
+
paths = @inspector.clean(paths)
|
37
38
|
return @runner.run(paths) unless paths.empty?
|
38
39
|
true
|
39
40
|
end
|
@@ -1,46 +1,70 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Guard
|
3
3
|
class Minitest
|
4
|
-
|
5
|
-
class << self
|
6
|
-
|
7
|
-
def clean(paths)
|
8
|
-
paths.uniq!
|
9
|
-
paths.compact!
|
10
|
-
paths = paths.select { |p| test_file?(p) || test_folder?(p) }
|
11
|
-
|
12
|
-
paths.dup.each do |path|
|
13
|
-
if File.directory?(path)
|
14
|
-
paths.delete(path)
|
15
|
-
paths += Dir.glob("#{path}/**/test_*.rb") + Dir.glob('test/**/*_test.rb') + Dir.glob("#{path}/**/*_spec.rb")
|
16
|
-
end
|
17
|
-
end
|
4
|
+
class Inspector
|
18
5
|
|
19
|
-
|
20
|
-
paths.compact!
|
21
|
-
clear_test_files_list
|
22
|
-
paths
|
23
|
-
end
|
6
|
+
attr_reader :test_folders, :test_file_patterns
|
24
7
|
|
25
|
-
|
8
|
+
def initialize(test_folders, test_file_patterns)
|
9
|
+
@test_folders = test_folders.uniq.compact.freeze
|
10
|
+
@test_file_patterns = test_file_patterns.uniq.compact.freeze
|
11
|
+
end
|
26
12
|
|
27
|
-
|
28
|
-
|
29
|
-
|
13
|
+
def clean_all
|
14
|
+
clean self.test_folders
|
15
|
+
end
|
30
16
|
|
31
|
-
|
32
|
-
|
33
|
-
|
17
|
+
def clean(paths)
|
18
|
+
paths = paths.uniq.compact unless paths == @test_folders
|
19
|
+
paths = paths.select { |p| test_file?(p) || test_folder?(p) }
|
34
20
|
|
35
|
-
|
36
|
-
|
21
|
+
paths.dup.each do |path|
|
22
|
+
if File.directory?(path)
|
23
|
+
paths.delete(path)
|
24
|
+
paths += test_files_for_pathes([path])
|
25
|
+
end
|
37
26
|
end
|
38
27
|
|
39
|
-
|
40
|
-
|
41
|
-
|
28
|
+
paths.uniq!
|
29
|
+
paths.compact!
|
30
|
+
clear_test_files_list
|
31
|
+
paths
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def test_folder_regex
|
36
|
+
@test_folder_regex ||= (
|
37
|
+
folders= self.test_folders.map {|f| Regexp.quote f}.join '|'
|
38
|
+
Regexp.new("^/?(?:#{folders})(?:/|$)")
|
39
|
+
)
|
40
|
+
end
|
42
41
|
|
42
|
+
def test_folder?(path)
|
43
|
+
path.match(test_folder_regex) && !path.match(/\..+$/) && File.directory?(path)
|
43
44
|
end
|
45
|
+
|
46
|
+
def test_file?(path)
|
47
|
+
test_files.include?(path)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_files
|
51
|
+
@test_files ||= test_files_for_pathes(self.test_folders)
|
52
|
+
end
|
53
|
+
|
54
|
+
def join_for_glob(fragments)
|
55
|
+
"{#{fragments.join ','}}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_files_for_pathes(pathes)
|
59
|
+
pathes= join_for_glob(pathes)
|
60
|
+
files= join_for_glob(self.test_file_patterns)
|
61
|
+
Dir.glob(pathes + '/**/' + files)
|
62
|
+
end
|
63
|
+
|
64
|
+
def clear_test_files_list
|
65
|
+
@test_files = nil
|
66
|
+
end
|
67
|
+
|
44
68
|
end
|
45
69
|
end
|
46
|
-
end
|
70
|
+
end
|
@@ -17,8 +17,12 @@ module Guard
|
|
17
17
|
:notify => true,
|
18
18
|
:bundler => File.exist?("#{Dir.pwd}/Gemfile"),
|
19
19
|
:rubygems => false,
|
20
|
-
:drb => false
|
20
|
+
:drb => false,
|
21
|
+
:test_folders => %w[test spec],
|
22
|
+
:test_file_patterns => %w[*_test.rb test_*.rb *_spec.rb],
|
21
23
|
}.merge(options)
|
24
|
+
[:test_folders,:test_file_patterns].each {|k| (@options[k]= [@options[k]].flatten.uniq.compact).freeze}
|
25
|
+
options= options.freeze
|
22
26
|
end
|
23
27
|
|
24
28
|
def run(paths, options = {})
|
@@ -51,6 +55,14 @@ module Guard
|
|
51
55
|
@options[:drb]
|
52
56
|
end
|
53
57
|
|
58
|
+
def test_folders
|
59
|
+
@options[:test_folders]
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_file_patterns
|
63
|
+
@options[:test_file_patterns]
|
64
|
+
end
|
65
|
+
|
54
66
|
private
|
55
67
|
|
56
68
|
def minitest_command(paths)
|
@@ -58,13 +70,22 @@ module Guard
|
|
58
70
|
cmd_parts << "bundle exec" if bundler?
|
59
71
|
if drb?
|
60
72
|
cmd_parts << 'testdrb'
|
61
|
-
cmd_parts <<
|
62
|
-
|
73
|
+
cmd_parts << "-r #{File.expand_path('../runners/default_runner.rb', __FILE__)}"
|
74
|
+
if notify?
|
75
|
+
cmd_parts << '-e \'::GUARD_NOTIFY=true\''
|
76
|
+
else
|
77
|
+
cmd_parts << '-e \'::GUARD_NOTIFY=false\''
|
78
|
+
end
|
79
|
+
test_folders.each do |f|
|
80
|
+
cmd_parts << "#{f}/test_helper.rb" if File.exist?("#{f}/test_helper.rb")
|
81
|
+
cmd_parts << "#{f}/spec_helper.rb" if File.exist?("#{f}/spec_helper.rb")
|
82
|
+
end
|
63
83
|
paths.each do |path|
|
64
84
|
cmd_parts << "./#{path}"
|
65
85
|
end
|
66
86
|
else
|
67
|
-
cmd_parts << 'ruby
|
87
|
+
cmd_parts << 'ruby'
|
88
|
+
cmd_parts.concat test_folders.map{|f| %[-I"#{f}"]}
|
68
89
|
cmd_parts << '-r rubygems' if rubygems?
|
69
90
|
cmd_parts << '-r bundler/setup' if bundler?
|
70
91
|
paths.each do |path|
|
@@ -80,7 +101,9 @@ module Guard
|
|
80
101
|
cmd_parts << "--seed #{seed}" unless seed.nil?
|
81
102
|
cmd_parts << '--verbose' if verbose?
|
82
103
|
end
|
83
|
-
cmd_parts.join(' ')
|
104
|
+
cmd= cmd_parts.join(' ')
|
105
|
+
puts "Running: #{cmd}\n\n" if verbose?
|
106
|
+
cmd
|
84
107
|
end
|
85
108
|
|
86
109
|
end
|
@@ -10,7 +10,7 @@ module MiniTest
|
|
10
10
|
start = Time.now
|
11
11
|
run_without_guard(args)
|
12
12
|
duration = Time.now - start
|
13
|
-
Guard::MinitestNotifier.notify(test_count, assertion_count, failures, errors, skips, duration) if GUARD_NOTIFY
|
13
|
+
::Guard::MinitestNotifier.notify(test_count, assertion_count, failures, errors, skips, duration) if GUARD_NOTIFY
|
14
14
|
end
|
15
15
|
|
16
16
|
end
|
@@ -11,7 +11,7 @@ module MiniTest
|
|
11
11
|
start = Time.now
|
12
12
|
_run_anything_without_guard(type)
|
13
13
|
duration = Time.now - start
|
14
|
-
Guard::MinitestNotifier.notify(test_count, assertion_count, failures, errors, skips, duration) if GUARD_NOTIFY
|
14
|
+
::Guard::MinitestNotifier.notify(test_count, assertion_count, failures, errors, skips, duration) if GUARD_NOTIFY
|
15
15
|
end
|
16
16
|
rescue NameError
|
17
17
|
puts "*** WARN: if you use MiniTest 1, please add version option in your 'Guardfile`."
|
@@ -1,11 +1,15 @@
|
|
1
1
|
guard 'minitest' do
|
2
2
|
# with Minitest::Unit
|
3
|
-
watch(%r|^test/test_(.*)\.rb|)
|
3
|
+
watch(%r|^test/(.*)\/?test_(.*)\.rb|)
|
4
4
|
watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
5
5
|
watch(%r|^test/test_helper\.rb|) { "test" }
|
6
6
|
|
7
7
|
# with Minitest::Spec
|
8
8
|
# watch(%r|^spec/(.*)_spec\.rb|)
|
9
|
-
# watch(%r|^lib/(.*)\.rb|)
|
9
|
+
# watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
10
10
|
# watch(%r|^spec/spec_helper\.rb|) { "spec" }
|
11
|
+
|
12
|
+
# Rails
|
13
|
+
# watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/functional/#{m[1]}_test.rb" }
|
14
|
+
# watch(%r|^app/models/(.*)\.rb|) { |m| "test/unit/#{m[1]}_test.rb" }
|
11
15
|
end
|
metadata
CHANGED
@@ -1,112 +1,107 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-minitest
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Yann Lugrin
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-02-21 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: guard
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70142535118700 !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
18
|
+
requirements:
|
22
19
|
- - ~>
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
25
22
|
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: minitest
|
29
23
|
prerelease: false
|
30
|
-
|
24
|
+
version_requirements: *70142535118700
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: minitest
|
27
|
+
requirement: &70142535117960 !ruby/object:Gem::Requirement
|
31
28
|
none: false
|
32
|
-
requirements:
|
33
|
-
- -
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 2.
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.1.0
|
36
33
|
type: :development
|
37
|
-
version_requirements: *id002
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: bundler
|
40
34
|
prerelease: false
|
41
|
-
|
35
|
+
version_requirements: *70142535117960
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: bundler
|
38
|
+
requirement: &70142535117260 !ruby/object:Gem::Requirement
|
42
39
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
46
43
|
version: 1.0.2
|
47
44
|
type: :development
|
48
|
-
version_requirements: *id003
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: mocha
|
51
45
|
prerelease: false
|
52
|
-
|
46
|
+
version_requirements: *70142535117260
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: mocha
|
49
|
+
requirement: &70142535116720 !ruby/object:Gem::Requirement
|
53
50
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
57
54
|
version: 0.9.8
|
58
55
|
type: :development
|
59
|
-
|
60
|
-
|
61
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70142535116720
|
58
|
+
description: Guard::Minitest automatically run your tests with MiniTest framework
|
59
|
+
(much like autotest)
|
60
|
+
email:
|
62
61
|
- yann.lugrin@sans-savoir.net
|
63
62
|
executables: []
|
64
|
-
|
65
63
|
extensions: []
|
66
|
-
|
67
64
|
extra_rdoc_files: []
|
68
|
-
|
69
|
-
files:
|
70
|
-
- lib/guard/minitest/runners/version_1_runner.rb
|
71
|
-
- lib/guard/minitest/runners/version_2_runner.rb
|
72
|
-
- lib/guard/minitest/runners/default_runner.rb
|
65
|
+
files:
|
73
66
|
- lib/guard/minitest/inspector.rb
|
74
|
-
- lib/guard/minitest/templates/Guardfile
|
75
67
|
- lib/guard/minitest/notifier.rb
|
76
68
|
- lib/guard/minitest/runner.rb
|
69
|
+
- lib/guard/minitest/runners/default_runner.rb
|
70
|
+
- lib/guard/minitest/runners/version_1_runner.rb
|
71
|
+
- lib/guard/minitest/runners/version_2_runner.rb
|
72
|
+
- lib/guard/minitest/templates/Guardfile
|
77
73
|
- lib/guard/minitest/version.rb
|
78
74
|
- lib/guard/minitest.rb
|
79
75
|
- LICENSE
|
80
76
|
- README.rdoc
|
81
|
-
has_rdoc: true
|
82
77
|
homepage: http://rubygems.org/gems/guard-minitest
|
83
78
|
licenses: []
|
84
|
-
|
85
79
|
post_install_message:
|
86
|
-
rdoc_options:
|
80
|
+
rdoc_options:
|
87
81
|
- --charset=UTF-8
|
88
82
|
- --main=README.rdoc
|
89
83
|
- --exclude='(lib|test|spec)|(Gem|Guard|Rake)file'
|
90
|
-
require_paths:
|
84
|
+
require_paths:
|
91
85
|
- lib
|
92
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
87
|
none: false
|
94
|
-
requirements:
|
95
|
-
- -
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version:
|
98
|
-
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
hash: -417848504522317774
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
96
|
none: false
|
100
|
-
requirements:
|
101
|
-
- -
|
102
|
-
- !ruby/object:Gem::Version
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
103
100
|
version: 1.3.6
|
104
101
|
requirements: []
|
105
|
-
|
106
102
|
rubyforge_project: guard-minitest
|
107
|
-
rubygems_version: 1.
|
103
|
+
rubygems_version: 1.8.10
|
108
104
|
signing_key:
|
109
105
|
specification_version: 3
|
110
106
|
summary: Guard gem for MiniTest framework
|
111
107
|
test_files: []
|
112
|
-
|