guard-minitest 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,7 @@ module Guard
7
7
 
8
8
  autoload :Runner, 'guard/minitest/runner'
9
9
  autoload :Inspector, 'guard/minitest/inspector'
10
+ autoload :Notifier, 'guard/minitest/notifier'
10
11
 
11
12
  def start
12
13
  Runner.set_seed(options)
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ module Guard
3
+ class Minitest
4
+ class Notifier
5
+
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
13
+ end
14
+
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
24
+ end
25
+
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
32
+
33
+ end
34
+ end
35
+ end
@@ -33,6 +33,7 @@ module Guard
33
33
  paths.each do |path|
34
34
  cmd_parts << "-r #{path}"
35
35
  end
36
+ cmd_parts << "-r #{File.expand_path('../runners/default_runner.rb', __FILE__)}"
36
37
  cmd_parts << '-e \'MiniTest::Unit.autorun\''
37
38
  cmd_parts << '--'
38
39
  cmd_parts << "--seed #{seed}"
@@ -0,0 +1,58 @@
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
+ self.help = ['--seed', options[:seed]]
16
+ self.help << ['--verbose'] if options[:verbose]
17
+ self.help = self.help.join(' ')
18
+
19
+ run_all_tests
20
+
21
+ return failures + errors if @test_count > 0 # or return nil...
22
+ rescue Interrupt
23
+ abort 'Interrupted'
24
+ end
25
+
26
+ def drive_tests(filters = /./)
27
+ run_test_suites(filters)
28
+ end
29
+ end
30
+
31
+ # Rewrite default runner to use notification
32
+ def run_all_tests
33
+ @@out.puts "Test run options: #{help}"
34
+ @@out.puts
35
+ @@out.puts 'Started'
36
+
37
+ start = Time.now
38
+ drive_tests(/./)
39
+ duration = Time.now - start
40
+
41
+ @@out.puts
42
+ @@out.puts "Finished in %.6f seconds, %.4f tests/s, %.4f assertions/s." %
43
+ [duration, test_count / duration, assertion_count / duration]
44
+
45
+ report.each_with_index do |msg, i|
46
+ @@out.puts "\n%3d) %s" % [i + 1, msg]
47
+ end
48
+
49
+ @@out.puts
50
+
51
+ status
52
+ Guard::Minitest::Notifier.notify(test_count, assertion_count, failures, errors, skips, duration)
53
+
54
+ @@out.puts
55
+ @@out.puts "Test run options: #{help}"
56
+ end
57
+ end
58
+ end
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Guard
3
3
  module MinitestVersion
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-minitest
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yann Lugrin
@@ -90,8 +90,10 @@ extensions: []
90
90
  extra_rdoc_files: []
91
91
 
92
92
  files:
93
+ - lib/guard/minitest/runners/default_runner.rb
93
94
  - lib/guard/minitest/inspector.rb
94
95
  - lib/guard/minitest/templates/Guardfile
96
+ - lib/guard/minitest/notifier.rb
95
97
  - lib/guard/minitest/runner.rb
96
98
  - lib/guard/minitest/version.rb
97
99
  - lib/guard/minitest.rb