guard-minitest-decisiv 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.
@@ -0,0 +1,117 @@
1
+ = Guard::Minitest
2
+
3
+ Minitest guard allows to automatically & intelligently launch tests with
4
+ {minitest framework}[http://github.com/seattlerb/minitest] when files are modified.
5
+
6
+ - Compatible with MiniTest 1.7.x & 2.x
7
+ - Tested on Ruby 1.8.6, 1.8.7 & 1.9.2.
8
+
9
+ == Install
10
+
11
+ Please be sure to have {guard}[http://github.com/guard/guard] installed before continue.
12
+
13
+ Install the gem:
14
+
15
+ gem install guard-minitest
16
+
17
+ Add it to your Gemfile (inside test group):
18
+
19
+ gem 'guard-minitest'
20
+
21
+ Add guard definition to your Guardfile by running this command:
22
+
23
+ guard init minitest
24
+
25
+ == Usage
26
+
27
+ Please read {guard usage doc}[http://github.com/guard/guard#readme]
28
+
29
+ == Guardfile
30
+
31
+ Minitest guard can be really be adapated to all kind of projects.
32
+ Please read {guard doc}[http://github.com/guard/guard#readme] for more info about Guardfile DSL.
33
+
34
+ === Standard ruby gems with Minitest::Unit
35
+
36
+ guard 'minitest' do
37
+ watch(%r|^test/test_(.*)\.rb|)
38
+ watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
39
+ watch(%r|^test/test_helper\.rb|) { "test" }
40
+ end
41
+
42
+ === Standard ruby gems with Minitest::Spec
43
+
44
+ guard 'minitest' do
45
+ watch(%r|^spec/(.*)_spec\.rb|)
46
+ watch(%r|^lib/(.*)\.rb|) { |m| "spec/#{m[1]}_spec.rb" }
47
+ watch(%r|^spec/spec_helper\.rb|) { "spec" }
48
+ end
49
+
50
+ == Options
51
+
52
+ You can specify the paths for "test all", perhaps to skip slow/remote/profiling tests:
53
+
54
+ guard 'minitest', :all => %w{test/unit test/functional test/integration test/lib}
55
+ ...
56
+ end
57
+
58
+ You can force minitest seed with:
59
+
60
+ guard 'minitest', :seed => 12345 do
61
+ ...
62
+ end
63
+
64
+ You can set minitest verbose mode with:
65
+
66
+ guard 'minitest', :verbose => true do
67
+ ...
68
+ end
69
+
70
+ You can colour the test output (via minitest/pride) with:
71
+
72
+ guard 'minitest', :colour => true do
73
+ ...
74
+ end
75
+ or
76
+ guard 'minitest', :color => true, :rubygems => true do
77
+ ...
78
+ end
79
+
80
+ (Remark : the "minitest" gem must be installed -> unless you have a Gemfile, you must also specify either :bundler or :rubygems)
81
+
82
+
83
+ You can disable desktop notification with:
84
+
85
+ guard 'minitest', :notify => false do
86
+ ...
87
+ end
88
+
89
+ You can disable bundler usage to run minitest with:
90
+
91
+ guard 'minitest', :bundler => false do
92
+ ...
93
+ end
94
+
95
+ You can enable rubygems usage to run minitest (only if bundler is not present or disabale) with:
96
+
97
+ guard 'minitest', :rubygems => true do
98
+ ...
99
+ end
100
+
101
+ If you use {spork-testunit}[https://github.com/timcharper/spork-testunit] you can enable it with (you'll have to load it before):
102
+
103
+ guard 'minitest', :drb => true do
104
+ ...
105
+ end
106
+
107
+ == Development
108
+
109
+ - Source hosted at {GitHub}[http://github.com/guard/guard-minitest]
110
+ - Report issues/Questions/Feature requests on {GitHub Issues}[http://github.com/guard/guard-minitest/issues]
111
+
112
+ Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
113
+ you make.
114
+
115
+ == Authors
116
+
117
+ {Yann Lugrin}[http://github.com/yannlugrin]
@@ -0,0 +1,41 @@
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 initialize(watchers = [], options = {})
12
+ super
13
+
14
+ @runner ||= Runner.new(options)
15
+ end
16
+
17
+ def start
18
+ true
19
+ end
20
+
21
+ def stop
22
+ true
23
+ end
24
+
25
+ def reload
26
+ true
27
+ end
28
+
29
+ def run_all
30
+ paths = Inspector.clean(@runner.all)
31
+ return @runner.run(paths, :message => 'Running all tests') unless paths.empty?
32
+ true
33
+ end
34
+
35
+ def run_on_change(paths = [])
36
+ paths = Inspector.clean(paths)
37
+ return @runner.run(paths) unless paths.empty?
38
+ true
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,48 @@
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
+ %w{test_*.rb *_test.rb *_spec.rb}.each do |file_pattern|
16
+ paths += Dir.glob(File.join(path,'**', file_pattern))
17
+ end
18
+ end
19
+ end
20
+
21
+ paths.uniq!
22
+ paths.compact!
23
+ clear_test_files_list
24
+ paths
25
+ end
26
+
27
+ private
28
+
29
+ def test_folder?(path)
30
+ path.match(/^\/?(test|spec)/) && !path.match(/\..+$/) && File.directory?(path)
31
+ end
32
+
33
+ def test_file?(path)
34
+ test_files.include?(path)
35
+ end
36
+
37
+ def test_files
38
+ @test_files ||= Dir.glob('test/**/test_*.rb') + Dir.glob('test/**/*_test.rb') + Dir.glob('{test,spec}/**/*_spec.rb')
39
+ end
40
+
41
+ def clear_test_files_list
42
+ @test_files = nil
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ require 'guard/notifier'
3
+
4
+ module Guard
5
+ class MinitestNotifier
6
+
7
+ def self.guard_message(test_count, assertion_count, failure_count, error_count, skip_count, duration)
8
+ message = "#{test_count} examples, #{assertion_count} assertions, #{failure_count} failures, #{error_count} errors"
9
+ if skip_count > 0
10
+ message << " (#{skip_count} skips)"
11
+ end
12
+ message << "\nin %.6f seconds, %.4f tests/s, %.4f assertions/s." % [duration, test_count / duration, assertion_count / duration]
13
+ message
14
+ end
15
+
16
+ # failed | pending (skip) | success
17
+ def self.guard_image(failure_count, skip_count)
18
+ icon = if failure_count > 0
19
+ :failed
20
+ elsif skip_count > 0
21
+ :pending
22
+ else
23
+ :success
24
+ end
25
+ end
26
+
27
+ def self.notify(test_count, assertion_count, failure_count, error_count, skip_count, duration)
28
+ message = guard_message(test_count, assertion_count, failure_count, error_count, skip_count, duration)
29
+ image = guard_image(failure_count + error_count, skip_count)
30
+
31
+ ::Guard::Notifier.notify(message, :title => 'MiniTest results', :image => image)
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,105 @@
1
+ # encoding: utf-8
2
+ module Guard
3
+ class Minitest
4
+ class Runner
5
+
6
+ class << self
7
+
8
+ def run(paths = [], options = {})
9
+ Runner.new(options).run(paths, options)
10
+ end
11
+
12
+ end
13
+
14
+ def initialize(options = {})
15
+ @options = {
16
+ :verbose => false,
17
+ :notify => true,
18
+ :bundler => File.exist?("#{Dir.pwd}/Gemfile"),
19
+ :rubygems => false,
20
+ :drb => false,
21
+ :colour => false,
22
+ :color => false,
23
+ :all => %w{test spec}
24
+ }.merge(options)
25
+
26
+ @options[:all] = [@options[:all]].flatten
27
+ end
28
+
29
+ def run(paths, options = {})
30
+ message = options[:message] || "Running: #{paths.join(' ')}"
31
+ UI.info message, :reset => true
32
+ system(minitest_command(paths))
33
+ end
34
+
35
+ def all
36
+ @options[:all]
37
+ end
38
+
39
+ def seed
40
+ @options[:seed]
41
+ end
42
+
43
+ def verbose?
44
+ @options[:verbose]
45
+ end
46
+
47
+ def notify?
48
+ @options[:notify]
49
+ end
50
+
51
+ def bundler?
52
+ @options[:bundler]
53
+ end
54
+
55
+ def rubygems?
56
+ !bundler? && @options[:rubygems]
57
+ end
58
+
59
+ def drb?
60
+ @options[:drb]
61
+ end
62
+
63
+ def colour?
64
+ gems_can_be_loaded = rubygems? || bundler?
65
+ gems_can_be_loaded && (@options[:colour] || @options[:color])
66
+ end
67
+ alias color? colour?
68
+
69
+ private
70
+
71
+ def minitest_command(paths)
72
+ cmd_parts = []
73
+ cmd_parts << "bundle exec" if bundler?
74
+ if drb?
75
+ cmd_parts << 'testdrb'
76
+ cmd_parts << 'test/test_helper.rb' if File.exist?('test/test_helper.rb')
77
+ cmd_parts << 'spec/spec_helper.rb' if File.exist?('spec/spec_helper.rb')
78
+ paths.each do |path|
79
+ cmd_parts << "./#{path}"
80
+ end
81
+ else
82
+ cmd_parts << 'ruby -Itest -Ispec'
83
+ cmd_parts << '-r rubygems' if rubygems?
84
+ cmd_parts << '-r bundler/setup' if bundler?
85
+ cmd_parts << '-rminitest/pride' if colour?
86
+ paths.each do |path|
87
+ cmd_parts << "-r ./#{path}"
88
+ end
89
+ cmd_parts << "-r #{File.expand_path('../runners/default_runner.rb', __FILE__)}"
90
+ if notify?
91
+ cmd_parts << '-e \'GUARD_NOTIFY=true; MiniTest::Unit.autorun\''
92
+ else
93
+ cmd_parts << '-e \'GUARD_NOTIFY=false; MiniTest::Unit.autorun\''
94
+ end
95
+ cmd_parts << '--'
96
+ cmd_parts << "--seed #{seed}" unless seed.nil?
97
+ cmd_parts << '--verbose' if verbose?
98
+ end
99
+ cmd_parts.join(' ')
100
+ end
101
+
102
+ end
103
+ end
104
+ end
105
+
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ require 'minitest/unit'
3
+
4
+ if MiniTest::Unit::VERSION =~ /^1/
5
+ load File.expand_path('../version_1_runner.rb', __FILE__)
6
+ else
7
+ load File.expand_path('../version_2_runner.rb', __FILE__)
8
+ end
@@ -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
@@ -0,0 +1,15 @@
1
+ guard 'minitest' do
2
+ # with Minitest::Unit
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
+
7
+ # with Minitest::Spec
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
+
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" }
15
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ module Guard
3
+ module MinitestVersion
4
+ VERSION = '0.4.1'
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-minitest-decisiv
3
+ version: !ruby/object:Gem::Version
4
+ hash: 13
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 4
9
+ - 1
10
+ version: 0.4.1
11
+ platform: ruby
12
+ authors:
13
+ - Yann Lugrin
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-01-18 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: guard
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ - 4
32
+ version: "0.4"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: minitest
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 11
44
+ segments:
45
+ - 2
46
+ - 1
47
+ - 0
48
+ version: 2.1.0
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: bundler
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 19
60
+ segments:
61
+ - 1
62
+ - 0
63
+ - 2
64
+ version: 1.0.2
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 with MiniTest framework (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/notifier.rb
95
+ - lib/guard/minitest/runner.rb
96
+ - lib/guard/minitest/runners/default_runner.rb
97
+ - lib/guard/minitest/runners/version_1_runner.rb
98
+ - lib/guard/minitest/runners/version_2_runner.rb
99
+ - lib/guard/minitest/templates/Guardfile
100
+ - lib/guard/minitest/version.rb
101
+ - lib/guard/minitest.rb
102
+ - LICENSE
103
+ - README.rdoc
104
+ homepage: http://github.com/DecisivInc/guard-minitest
105
+ licenses: []
106
+
107
+ post_install_message:
108
+ rdoc_options:
109
+ - --charset=UTF-8
110
+ - --main=README.rdoc
111
+ - --exclude='(lib|test|spec)|(Gem|Guard|Rake)file'
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ hash: 3
120
+ segments:
121
+ - 0
122
+ version: "0"
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ hash: 23
129
+ segments:
130
+ - 1
131
+ - 3
132
+ - 6
133
+ version: 1.3.6
134
+ requirements: []
135
+
136
+ rubyforge_project: guard-minitest-decisiv
137
+ rubygems_version: 1.8.12
138
+ signing_key:
139
+ specification_version: 3
140
+ summary: Guard gem for MiniTest framework
141
+ test_files: []
142
+