guard-minitest 0.2.2 → 0.3.0

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.
@@ -49,18 +49,36 @@ Please read {guard doc}[http://github.com/guard/guard#readme] for more info abou
49
49
 
50
50
  == Options
51
51
 
52
- You can force seed for minitest with:
52
+ You can force minitest seed with:
53
53
 
54
54
  guard 'minitest', :seed => 12345 do
55
55
  ...
56
56
  end
57
57
 
58
- You can set verbose mode for minitest with:
58
+ You can set minitest verbose mode with:
59
59
 
60
60
  guard 'minitest', :verbose => true do
61
61
  ...
62
62
  end
63
63
 
64
+ You can disable desktop notification with:
65
+
66
+ guard 'minitest', :notify => false do
67
+ ...
68
+ end
69
+
70
+ You can disable bundler usage to run minitest with:
71
+
72
+ guard 'minitest', :bundler => false do
73
+ ...
74
+ end
75
+
76
+ You can enable rubygems usage to run minitest (only if bundler is not present or disabale) with:
77
+
78
+ guard 'minitest', :rubygems => true do
79
+ ...
80
+ end
81
+
64
82
  == Development
65
83
 
66
84
  - Source hosted at {GitHub}[http://github.com/guard/guard-minitest]
@@ -7,21 +7,22 @@ module Guard
7
7
 
8
8
  autoload :Runner, 'guard/minitest/runner'
9
9
  autoload :Inspector, 'guard/minitest/inspector'
10
- autoload :Notifier, 'guard/minitest/notifier'
11
10
 
12
11
  def start
13
- Runner.set_seed(options)
14
- Runner.set_verbose(options)
12
+ @runner ||= Runner.new(options)
13
+ true
15
14
  end
16
15
 
17
16
  def run_all
18
17
  paths = Inspector.clean(['test', 'spec'])
19
- Runner.run(paths, :message => 'Running all tests') unless paths.empty?
18
+ return @runner.run(paths, :message => 'Running all tests') unless paths.empty?
19
+ true
20
20
  end
21
21
 
22
22
  def run_on_change(paths = [])
23
23
  paths = Inspector.clean(paths)
24
- Runner.run(paths) unless paths.empty?
24
+ return @runner.run(paths) unless paths.empty?
25
+ true
25
26
  end
26
27
  end
27
28
  end
@@ -1,35 +1,33 @@
1
1
  # encoding: utf-8
2
2
  module Guard
3
- class Minitest
4
- class Notifier
3
+ class MinitestNotifier
5
4
 
6
- def self.guard_message(test_count, assertion_count, failure_count, error_count, skip_count, duration)
7
- message = "#{test_count} examples, #{assertion_count} assertions, #{failure_count} failures, #{error_count} errors"
8
- if skip_count > 0
9
- message << " (#{skip_count} skips)"
10
- end
11
- message << "\nin %.6f seconds, %.4f tests/s, %.4f assertions/s." % [duration, test_count / duration, assertion_count / duration]
12
- message
5
+ def self.guard_message(test_count, assertion_count, failure_count, error_count, skip_count, duration)
6
+ message = "#{test_count} examples, #{assertion_count} assertions, #{failure_count} failures, #{error_count} errors"
7
+ if skip_count > 0
8
+ message << " (#{skip_count} skips)"
13
9
  end
10
+ message << "\nin %.6f seconds, %.4f tests/s, %.4f assertions/s." % [duration, test_count / duration, assertion_count / duration]
11
+ message
12
+ end
14
13
 
15
- # failed | pending (skip) | success
16
- def self.guard_image(failure_count, skip_count)
17
- icon = if failure_count > 0
18
- :failed
19
- elsif skip_count > 0
20
- :pending
21
- else
22
- :success
23
- end
14
+ # failed | pending (skip) | success
15
+ def self.guard_image(failure_count, skip_count)
16
+ icon = if failure_count > 0
17
+ :failed
18
+ elsif skip_count > 0
19
+ :pending
20
+ else
21
+ :success
24
22
  end
23
+ end
25
24
 
26
- def self.notify(test_count, assertion_count, failure_count, error_count, skip_count, duration)
27
- message = guard_message(test_count, assertion_count, failure_count, error_count, skip_count, duration)
28
- image = guard_image(failure_count + error_count, skip_count)
29
-
30
- ::Guard::Notifier.notify(message, :title => 'MiniTest results', :image => image)
31
- end
25
+ def self.notify(test_count, assertion_count, failure_count, error_count, skip_count, duration)
26
+ message = guard_message(test_count, assertion_count, failure_count, error_count, skip_count, duration)
27
+ image = guard_image(failure_count + error_count, skip_count)
32
28
 
29
+ ::Guard::Notifier.notify(message, :title => 'MiniTest results', :image => image)
33
30
  end
31
+
34
32
  end
35
33
  end
@@ -2,50 +2,73 @@
2
2
  module Guard
3
3
  class Minitest
4
4
  class Runner
5
+
5
6
  class << self
6
- attr_reader :seed
7
7
 
8
- def set_seed(options = {})
9
- @seed = options[:seed]
8
+ def run(paths = [], options = {})
9
+ Runner.new(options).run(paths, options)
10
10
  end
11
11
 
12
- def set_verbose(options = {})
13
- @verbose = !!options[:verbose]
14
- end
12
+ end
15
13
 
16
- def verbose?
17
- !!@verbose
18
- end
14
+ def initialize(options = {})
15
+ @options = {
16
+ :verbose => false,
17
+ :notify => true,
18
+ :bundler => File.exist?("#{Dir.pwd}/Gemfile"),
19
+ :rubygems => false
20
+ }.merge(options)
21
+ end
19
22
 
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
23
+ def run(paths, options = {})
24
+ message = options[:message] || "Running: #{paths.join(' ')}"
25
+ UI.info message, :reset => true
26
+ system(minitest_command(paths))
27
+ end
25
28
 
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 << "-r #{File.expand_path('../runners/default_runner.rb', __FILE__)}"
37
- cmd_parts << '-e \'MiniTest::Unit.autorun\''
38
- cmd_parts << '--'
39
- cmd_parts << "--seed #{seed}" unless seed.nil?
40
- cmd_parts << '--verbose' if verbose?
41
- cmd_parts.join(' ')
42
- end
29
+ def seed
30
+ @options[:seed]
31
+ end
43
32
 
44
- def bundler?
45
- @bundler ||= File.exist?("#{Dir.pwd}/Gemfile")
46
- end
33
+ def verbose?
34
+ @options[:verbose]
35
+ end
47
36
 
37
+ def notify?
38
+ @options[:notify]
48
39
  end
40
+
41
+ def bundler?
42
+ @options[:bundler]
43
+ end
44
+
45
+ def rubygems?
46
+ !bundler? && @options[:rubygems]
47
+ end
48
+
49
+ private
50
+
51
+ def minitest_command(paths)
52
+ cmd_parts = []
53
+ cmd_parts << "bundle exec" if bundler?
54
+ cmd_parts << 'ruby -Itest -Ispec'
55
+ cmd_parts << '-r rubygems' if rubygems?
56
+ cmd_parts << '-r bundler/setup' if bundler?
57
+ paths.each do |path|
58
+ cmd_parts << "-r #{path}"
59
+ end
60
+ cmd_parts << "-r #{File.expand_path('../runners/default_runner.rb', __FILE__)}"
61
+ if notify?
62
+ cmd_parts << '-e \'GUARD_NOTIFY=true; MiniTest::Unit.autorun\''
63
+ else
64
+ cmd_parts << '-e \'GUARD_NOTIFY=false; MiniTest::Unit.autorun\''
65
+ end
66
+ cmd_parts << '--'
67
+ cmd_parts << "--seed #{seed}" unless seed.nil?
68
+ cmd_parts << '--verbose' if verbose?
69
+ cmd_parts.join(' ')
70
+ end
71
+
49
72
  end
50
73
  end
51
74
  end
@@ -54,7 +54,7 @@ module MiniTest
54
54
  @@out.puts
55
55
 
56
56
  status
57
- Guard::Minitest::Notifier.notify(test_count, assertion_count, failures, errors, skips, duration)
57
+ Guard::MinitestNotifier.notify(test_count, assertion_count, failures, errors, skips, duration) if GUARD_NOTIFY
58
58
 
59
59
  @@out.puts
60
60
  @@out.puts "Test run options: #{help}"
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Guard
3
3
  module MinitestVersion
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3.0'
5
5
  end
6
6
  end
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yann Lugrin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-24 00:00:00 +02:00
18
+ date: 2010-10-27 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 21
29
+ hash: 19
30
30
  segments:
31
31
  - 0
32
32
  - 2
33
- - 1
34
- version: 0.2.1
33
+ - 2
34
+ version: 0.2.2
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -106,8 +106,10 @@ homepage: http://rubygems.org/gems/guard-minitest
106
106
  licenses: []
107
107
 
108
108
  post_install_message:
109
- rdoc_options: []
110
-
109
+ rdoc_options:
110
+ - --charset=UTF-8
111
+ - --main=README.rdoc
112
+ - --exclude='(lib|test|spec)|(Gem|Guard|Rake)file'
111
113
  require_paths:
112
114
  - lib
113
115
  required_ruby_version: !ruby/object:Gem::Requirement