guard-minitest 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +73 -0
- data/lib/guard/minitest.rb +26 -0
- data/lib/guard/minitest/inspector.rb +46 -0
- data/lib/guard/minitest/runner.rb +55 -0
- data/lib/guard/minitest/templates/Guardfile +11 -0
- data/lib/guard/minitest/version.rb +6 -0
- metadata +137 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Yann Lugrin
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
= Guard::Minitest
|
2
|
+
|
3
|
+
Minitest guard allows to automatically & intelligently launch tests when files are modified.
|
4
|
+
|
5
|
+
- Compatible with MiniTest 1.7.x
|
6
|
+
- Tested on Ruby 1.8.7 & 1.9.2.
|
7
|
+
|
8
|
+
== Install
|
9
|
+
|
10
|
+
Please be sure to have {guard}[http://github.com/guard/guard] installed before continue.
|
11
|
+
|
12
|
+
Install the gem:
|
13
|
+
|
14
|
+
gem install guard-minitest
|
15
|
+
|
16
|
+
Add it to your Gemfile (inside test group):
|
17
|
+
|
18
|
+
gem 'guard-minitest'
|
19
|
+
|
20
|
+
Add guard definition to your Guardfile by running this command:
|
21
|
+
|
22
|
+
guard init minitest
|
23
|
+
|
24
|
+
== Usage
|
25
|
+
|
26
|
+
Please read {guard usage doc}[http://github.com/guard/guard#readme]
|
27
|
+
|
28
|
+
== Guardfile
|
29
|
+
|
30
|
+
Minitest guard can be really be adapated to all kind of projects.
|
31
|
+
Please read {guard doc}[http://github.com/guard/guard#readme] for more info about Guardfile DSL.
|
32
|
+
|
33
|
+
=== Standard ruby gems with Minitest::Unit
|
34
|
+
|
35
|
+
guard 'minitest' do
|
36
|
+
watch('^test/test_(.*).rb')
|
37
|
+
watch('^lib/(.*)([^/]+)\.rb') { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
38
|
+
watch('^test/test_helper.rb') { "test" }
|
39
|
+
end
|
40
|
+
|
41
|
+
=== Standard ruby gems with Minitest::Spec
|
42
|
+
|
43
|
+
guard 'minitest' do
|
44
|
+
watch('^spec/(.*)_spec.rb')
|
45
|
+
watch('^lib/(.*)\.rb') { |m| "spec/#{m[1]}_spec.rb" }
|
46
|
+
watch('^spec/spec_helper.rb') { "spec" }
|
47
|
+
end
|
48
|
+
|
49
|
+
== Options
|
50
|
+
|
51
|
+
You can force seed for minitest with:
|
52
|
+
|
53
|
+
guard 'minitest', :seed => 12345 do
|
54
|
+
...
|
55
|
+
end
|
56
|
+
|
57
|
+
You can set verbose mode for minitest with:
|
58
|
+
|
59
|
+
guard 'minitest', :verbose => true do
|
60
|
+
...
|
61
|
+
end
|
62
|
+
|
63
|
+
== Development
|
64
|
+
|
65
|
+
- Source hosted at {GitHub}[http://github.com/guard/guard-minitest]
|
66
|
+
- Report issues/Questions/Feature requests on {GitHub Issues}[http://github.com/guard/guard-minitest/issues]
|
67
|
+
|
68
|
+
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
|
69
|
+
you make.
|
70
|
+
|
71
|
+
== Authors
|
72
|
+
|
73
|
+
{Yann Lugrin}[http://github.com/yannlugrin]
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'guard'
|
3
|
+
require 'guard/guard'
|
4
|
+
|
5
|
+
module Guard
|
6
|
+
class Minitest < Guard
|
7
|
+
|
8
|
+
autoload :Runner, 'guard/minitest/runner'
|
9
|
+
autoload :Inspector, 'guard/minitest/inspector'
|
10
|
+
|
11
|
+
def start
|
12
|
+
Runner.set_seed(options)
|
13
|
+
Runner.set_verbose(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def run_all
|
17
|
+
paths = Inspector.clean(['test', 'spec'])
|
18
|
+
Runner.run(paths, :message => 'Running all tests') unless paths.empty?
|
19
|
+
end
|
20
|
+
|
21
|
+
def run_on_change(paths = [])
|
22
|
+
paths = Inspector.clean(paths)
|
23
|
+
Runner.run(Inspector.clean(paths)) unless paths.empty?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Guard
|
3
|
+
class Minitest
|
4
|
+
module Inspector
|
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
|
18
|
+
|
19
|
+
paths.uniq!
|
20
|
+
paths.compact!
|
21
|
+
clear_test_files_list
|
22
|
+
paths
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def test_folder?(path)
|
28
|
+
path.match(/^\/?(test|spec)/) && !path.match(/\..+$/) && File.directory?(path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_file?(path)
|
32
|
+
test_files.include?(path)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_files
|
36
|
+
@test_files ||= Dir.glob('test/**/test_*.rb') + Dir.glob('test/**/*_test.rb') + Dir.glob('{test,spec}/**/*_spec.rb')
|
37
|
+
end
|
38
|
+
|
39
|
+
def clear_test_files_list
|
40
|
+
@test_files = nil
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Guard
|
3
|
+
class Minitest
|
4
|
+
class Runner
|
5
|
+
class << self
|
6
|
+
attr_reader :seed
|
7
|
+
|
8
|
+
def set_seed(options = {})
|
9
|
+
@seed = options[:seed] ||= default_seed
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_verbose(options = {})
|
13
|
+
@verbose = !!options[:verbose]
|
14
|
+
end
|
15
|
+
|
16
|
+
def verbose?
|
17
|
+
!!@verbose
|
18
|
+
end
|
19
|
+
|
20
|
+
def run(paths, options = {})
|
21
|
+
message = options[:message] || "Running: #{paths.join(' ')}"
|
22
|
+
UI.info message, :reset => true
|
23
|
+
system(minitest_command(paths))
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def minitest_command(paths)
|
29
|
+
cmd_parts = []
|
30
|
+
cmd_parts << "bundle exec" if bundler?
|
31
|
+
cmd_parts << 'ruby -Itest -Ispec'
|
32
|
+
cmd_parts << '-r bundler/setup' if bundler?
|
33
|
+
paths.each do |path|
|
34
|
+
cmd_parts << "-r #{path}"
|
35
|
+
end
|
36
|
+
cmd_parts << '-e \'MiniTest::Unit.autorun\''
|
37
|
+
cmd_parts << '--'
|
38
|
+
cmd_parts << "--seed #{seed}"
|
39
|
+
cmd_parts << '--verbose' if verbose?
|
40
|
+
cmd_parts.join(' ')
|
41
|
+
end
|
42
|
+
|
43
|
+
def bundler?
|
44
|
+
@bundler ||= File.exist?("#{Dir.pwd}/Gemfile")
|
45
|
+
end
|
46
|
+
|
47
|
+
def default_seed
|
48
|
+
srand
|
49
|
+
srand % 0xFFFF
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
guard 'minitest' do
|
2
|
+
# with Minitest::Unit
|
3
|
+
watch('^test/test_(.*).rb')
|
4
|
+
watch('^lib/(.*)([^/]+)\.rb') { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
5
|
+
watch('^test/test_helper.rb') { "test" }
|
6
|
+
|
7
|
+
# with Minitest::Spec
|
8
|
+
# watch('^spec/(.*)_spec.rb')
|
9
|
+
# watch('^lib/(.*)\.rb') { |m| "spec/#{m[1]}_spec.rb" }
|
10
|
+
# watch('^spec/spec_helper.rb') { "spec" }
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-minitest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Yann Lugrin
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-20 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: guard
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: bundler
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 19
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 0
|
47
|
+
- 2
|
48
|
+
version: 1.0.2
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: minitest
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 11
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 7
|
63
|
+
- 0
|
64
|
+
version: 1.7.0
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: mocha
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 43
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
- 9
|
79
|
+
- 8
|
80
|
+
version: 0.9.8
|
81
|
+
type: :development
|
82
|
+
version_requirements: *id004
|
83
|
+
description: Guard::Minitest automatically run your tests (much like autotest)
|
84
|
+
email:
|
85
|
+
- yann.lugrin@sans-savoir.net
|
86
|
+
executables: []
|
87
|
+
|
88
|
+
extensions: []
|
89
|
+
|
90
|
+
extra_rdoc_files: []
|
91
|
+
|
92
|
+
files:
|
93
|
+
- lib/guard/minitest/inspector.rb
|
94
|
+
- lib/guard/minitest/templates/Guardfile
|
95
|
+
- lib/guard/minitest/runner.rb
|
96
|
+
- lib/guard/minitest/version.rb
|
97
|
+
- lib/guard/minitest.rb
|
98
|
+
- LICENSE
|
99
|
+
- README.rdoc
|
100
|
+
has_rdoc: true
|
101
|
+
homepage: http://rubygems.org/gems/guard-minitest
|
102
|
+
licenses: []
|
103
|
+
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
hash: 3
|
115
|
+
segments:
|
116
|
+
- 0
|
117
|
+
version: "0"
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 23
|
124
|
+
segments:
|
125
|
+
- 1
|
126
|
+
- 3
|
127
|
+
- 6
|
128
|
+
version: 1.3.6
|
129
|
+
requirements: []
|
130
|
+
|
131
|
+
rubyforge_project: guard-minitest
|
132
|
+
rubygems_version: 1.3.7
|
133
|
+
signing_key:
|
134
|
+
specification_version: 3
|
135
|
+
summary: Guard gem for Minitest
|
136
|
+
test_files: []
|
137
|
+
|