guard-minitest 0.3.0 → 0.4.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/lib/guard/minitest.rb +15 -1
- data/lib/guard/minitest/runner.rb +20 -5
- data/lib/guard/minitest/runners/version_1_runner.rb +17 -0
- data/lib/guard/minitest/runners/version_2_runner.rb +22 -0
- data/lib/guard/minitest/templates/Guardfile +6 -6
- data/lib/guard/minitest/version.rb +1 -1
- metadata +22 -19
- data/lib/guard/minitest/runners/default_runner.rb +0 -63
data/README.rdoc
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
= Guard::Minitest
|
2
2
|
|
3
3
|
Minitest guard allows to automatically & intelligently launch tests with
|
4
|
-
{minitest framework}[http://
|
4
|
+
{minitest framework}[http://github.com/seattlerb/minitest] when files are modified.
|
5
5
|
|
6
6
|
- Compatible with MiniTest 1.7.x
|
7
7
|
- Tested on Ruby 1.8.6, 1.8.7 & 1.9.2.
|
data/lib/guard/minitest.rb
CHANGED
@@ -8,8 +8,22 @@ module Guard
|
|
8
8
|
autoload :Runner, 'guard/minitest/runner'
|
9
9
|
autoload :Inspector, 'guard/minitest/inspector'
|
10
10
|
|
11
|
-
def
|
11
|
+
def initialize(watchers = [], options = {})
|
12
|
+
super
|
13
|
+
|
12
14
|
@runner ||= Runner.new(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def start
|
18
|
+
UI.info "Guard running MiniTest #{@runner.version}"
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def stop
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
def reload
|
13
27
|
true
|
14
28
|
end
|
15
29
|
|
@@ -12,11 +12,18 @@ module Guard
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def initialize(options = {})
|
15
|
+
minitest_version = begin
|
16
|
+
MiniTest::Unit.const_defined?(:VERSION) && MiniTest::Unit::VERSION =~ /^1/ ? 1 : 2
|
17
|
+
rescue
|
18
|
+
2
|
19
|
+
end
|
20
|
+
|
15
21
|
@options = {
|
16
|
-
:verbose
|
17
|
-
:notify
|
18
|
-
:bundler
|
19
|
-
:rubygems => false
|
22
|
+
:verbose => false,
|
23
|
+
:notify => true,
|
24
|
+
:bundler => File.exist?("#{Dir.pwd}/Gemfile"),
|
25
|
+
:rubygems => false,
|
26
|
+
:version => minitest_version
|
20
27
|
}.merge(options)
|
21
28
|
end
|
22
29
|
|
@@ -46,6 +53,10 @@ module Guard
|
|
46
53
|
!bundler? && @options[:rubygems]
|
47
54
|
end
|
48
55
|
|
56
|
+
def version
|
57
|
+
@options[:version].to_i
|
58
|
+
end
|
59
|
+
|
49
60
|
private
|
50
61
|
|
51
62
|
def minitest_command(paths)
|
@@ -57,7 +68,11 @@ module Guard
|
|
57
68
|
paths.each do |path|
|
58
69
|
cmd_parts << "-r #{path}"
|
59
70
|
end
|
60
|
-
|
71
|
+
if version == 1
|
72
|
+
cmd_parts << "-r #{File.expand_path('../runners/version_1_runner.rb', __FILE__)}"
|
73
|
+
else
|
74
|
+
cmd_parts << "-r #{File.expand_path('../runners/version_2_runner.rb', __FILE__)}"
|
75
|
+
end
|
61
76
|
if notify?
|
62
77
|
cmd_parts << '-e \'GUARD_NOTIFY=true; MiniTest::Unit.autorun\''
|
63
78
|
else
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'minitest/unit'
|
3
|
+
require 'guard/minitest/notifier'
|
4
|
+
|
5
|
+
module MiniTest
|
6
|
+
class MiniTest::Unit
|
7
|
+
|
8
|
+
alias_method :run_without_guard, :run
|
9
|
+
def run(args = [])
|
10
|
+
start = Time.now
|
11
|
+
run_without_guard(args)
|
12
|
+
duration = Time.now - start
|
13
|
+
Guard::MinitestNotifier.notify(test_count, assertion_count, failures, errors, skips, duration) if GUARD_NOTIFY
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'minitest/unit'
|
3
|
+
require 'guard/minitest/notifier'
|
4
|
+
|
5
|
+
module MiniTest
|
6
|
+
class MiniTest::Unit
|
7
|
+
|
8
|
+
begin
|
9
|
+
alias_method :_run_anything_without_guard, :_run_anything
|
10
|
+
def _run_anything(type)
|
11
|
+
start = Time.now
|
12
|
+
_run_anything_without_guard(type)
|
13
|
+
duration = Time.now - start
|
14
|
+
Guard::MinitestNotifier.notify(test_count, assertion_count, failures, errors, skips, duration) if GUARD_NOTIFY
|
15
|
+
end
|
16
|
+
rescue NameError
|
17
|
+
puts "*** WARN: if you use MiniTest 1, please add version option in your 'Guardfile`."
|
18
|
+
raise
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
guard 'minitest' do
|
2
2
|
# with Minitest::Unit
|
3
|
-
watch(
|
4
|
-
watch(
|
5
|
-
watch(
|
3
|
+
watch(%r|^test/test_(.*).rb|)
|
4
|
+
watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
5
|
+
watch(%r|^test/test_helper.rb|) { "test" }
|
6
6
|
|
7
7
|
# with Minitest::Spec
|
8
|
-
# watch(
|
9
|
-
# watch(
|
10
|
-
# watch(
|
8
|
+
# watch(%r|^spec/(.*)_spec.rb|)
|
9
|
+
# watch(%r|^lib/(.*)\.rb|) { |m| "spec/#{m[1]}_spec.rb" }
|
10
|
+
# watch(%r|^spec/spec_helper.rb|) { "spec" }
|
11
11
|
end
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 15424087
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
|
10
|
+
- rc
|
11
|
+
- 1
|
12
|
+
version: 0.4.0.rc1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Yann Lugrin
|
@@ -15,7 +17,7 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date:
|
20
|
+
date: 2011-05-23 00:00:00 +02:00
|
19
21
|
default_executable:
|
20
22
|
dependencies:
|
21
23
|
- !ruby/object:Gem::Dependency
|
@@ -35,35 +37,35 @@ dependencies:
|
|
35
37
|
type: :runtime
|
36
38
|
version_requirements: *id001
|
37
39
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
40
|
+
name: minitest
|
39
41
|
prerelease: false
|
40
42
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
43
|
none: false
|
42
44
|
requirements:
|
43
|
-
- -
|
45
|
+
- - ">="
|
44
46
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
47
|
+
hash: 15
|
46
48
|
segments:
|
47
|
-
- 1
|
48
|
-
- 0
|
49
49
|
- 2
|
50
|
-
|
50
|
+
- 0
|
51
|
+
- 0
|
52
|
+
version: 2.0.0
|
51
53
|
type: :development
|
52
54
|
version_requirements: *id002
|
53
55
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
56
|
+
name: bundler
|
55
57
|
prerelease: false
|
56
58
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
59
|
none: false
|
58
60
|
requirements:
|
59
|
-
- -
|
61
|
+
- - ">="
|
60
62
|
- !ruby/object:Gem::Version
|
61
|
-
hash:
|
63
|
+
hash: 19
|
62
64
|
segments:
|
63
65
|
- 1
|
64
|
-
-
|
66
|
+
- 0
|
65
67
|
- 2
|
66
|
-
version: 1.
|
68
|
+
version: 1.0.2
|
67
69
|
type: :development
|
68
70
|
version_requirements: *id003
|
69
71
|
- !ruby/object:Gem::Dependency
|
@@ -72,7 +74,7 @@ dependencies:
|
|
72
74
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
75
|
none: false
|
74
76
|
requirements:
|
75
|
-
- -
|
77
|
+
- - ">="
|
76
78
|
- !ruby/object:Gem::Version
|
77
79
|
hash: 43
|
78
80
|
segments:
|
@@ -92,7 +94,8 @@ extensions: []
|
|
92
94
|
extra_rdoc_files: []
|
93
95
|
|
94
96
|
files:
|
95
|
-
- lib/guard/minitest/runners/
|
97
|
+
- lib/guard/minitest/runners/version_1_runner.rb
|
98
|
+
- lib/guard/minitest/runners/version_2_runner.rb
|
96
99
|
- lib/guard/minitest/inspector.rb
|
97
100
|
- lib/guard/minitest/templates/Guardfile
|
98
101
|
- lib/guard/minitest/notifier.rb
|
@@ -135,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
138
|
requirements: []
|
136
139
|
|
137
140
|
rubyforge_project: guard-minitest
|
138
|
-
rubygems_version: 1.
|
141
|
+
rubygems_version: 1.6.2
|
139
142
|
signing_key:
|
140
143
|
specification_version: 3
|
141
144
|
summary: Guard gem for MiniTest framework
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'minitest/unit'
|
3
|
-
require 'guard/minitest/notifier'
|
4
|
-
|
5
|
-
module MiniTest
|
6
|
-
class Unit
|
7
|
-
|
8
|
-
# Compatibility with version 1.7
|
9
|
-
if VERSION <= '1.7.2'
|
10
|
-
attr_accessor :options, :help
|
11
|
-
|
12
|
-
def run(args = [])
|
13
|
-
self.options = process_args(args)
|
14
|
-
|
15
|
-
unless options[:seed] then
|
16
|
-
srand
|
17
|
-
options[:seed] = srand % 0xFFFF
|
18
|
-
end
|
19
|
-
|
20
|
-
self.help = ['--seed', options[:seed].to_s]
|
21
|
-
self.help << ['--verbose'] if options[:verbose]
|
22
|
-
self.help = self.help.join(' ')
|
23
|
-
|
24
|
-
run_all_tests
|
25
|
-
|
26
|
-
return failures + errors if @test_count > 0 # or return nil...
|
27
|
-
rescue Interrupt
|
28
|
-
abort 'Interrupted'
|
29
|
-
end
|
30
|
-
|
31
|
-
def drive_tests(filters = /./)
|
32
|
-
run_test_suites(filters)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# Rewrite default runner to use notification
|
37
|
-
def run_all_tests
|
38
|
-
@@out.puts "Test run options: #{help}"
|
39
|
-
@@out.puts
|
40
|
-
@@out.puts 'Started'
|
41
|
-
|
42
|
-
start = Time.now
|
43
|
-
drive_tests(/./)
|
44
|
-
duration = Time.now - start
|
45
|
-
|
46
|
-
@@out.puts
|
47
|
-
@@out.puts "Finished in %.6f seconds, %.4f tests/s, %.4f assertions/s." %
|
48
|
-
[duration, test_count / duration, assertion_count / duration]
|
49
|
-
|
50
|
-
report.each_with_index do |msg, i|
|
51
|
-
@@out.puts "\n%3d) %s" % [i + 1, msg]
|
52
|
-
end
|
53
|
-
|
54
|
-
@@out.puts
|
55
|
-
|
56
|
-
status
|
57
|
-
Guard::MinitestNotifier.notify(test_count, assertion_count, failures, errors, skips, duration) if GUARD_NOTIFY
|
58
|
-
|
59
|
-
@@out.puts
|
60
|
-
@@out.puts "Test run options: #{help}"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|