test_notifier 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,17 +10,23 @@ Autotest.add_hook :ran_command do |at|
10
10
  if rspec_matches
11
11
  _, examples, failures, _, pending = *rspec_matches
12
12
 
13
- stats = TestNotifier::Stats.new(:spec, :total => examples, :fail => failures, :pending => pending)
13
+ stats = TestNotifier::Stats.new(:spec, {
14
+ :count => examples,
15
+ :failures => failures,
16
+ :pending => pending
17
+ })
18
+
14
19
  TestNotifier.notify(:status => stats.status, :message => stats.message) unless examples.to_i.zero?
15
20
  elsif test_unit_matches
16
21
  _, tests, assertions, failures, errors = *test_unit_matches
17
22
 
18
23
  stats = TestNotifier::Stats.new(:test_unit, {
19
- :total => tests,
24
+ :count => tests,
20
25
  :assertions => assertions,
21
- :fail => failures,
22
- :errors => errors
26
+ :failures => failures,
27
+ :errors => errors
23
28
  })
29
+
24
30
  TestNotifier.notify(:status => stats.status, :message => stats.message) unless tests.to_i.zero?
25
31
  end
26
32
  rescue
@@ -9,11 +9,19 @@ class RSpec::Core::Formatters::BaseTextFormatter
9
9
 
10
10
  return if example_count.zero?
11
11
 
12
+ failure_filter = proc {|e|
13
+ e.instance_variable_get("@exception").class.name == "RSpec::Expectations::ExpectationNotMetError"
14
+ }
15
+
16
+ error_filter = proc {|e|
17
+ %w[RSpec::Expectations::ExpectationNotMetError NilClass].include?(e.instance_variable_get("@exception").class.name)
18
+ }
19
+
12
20
  stats = TestNotifier::Stats.new(:rspec, {
13
- :total => example_count,
14
- :fail => failure_count,
15
- :pending => pending_count,
16
- :errors => examples.reject {|e| e.instance_variable_get("@exception").nil?}.count
21
+ :count => example_count,
22
+ :failures => examples.select(&failure_filter).count,
23
+ :pending => pending_count,
24
+ :errors => examples.reject(&error_filter).count
17
25
  })
18
26
 
19
27
  TestNotifier.notify(:status => stats.status, :message => stats.message)
@@ -10,12 +10,12 @@ class Spec::Runner::Formatter::BaseTextFormatter
10
10
  return if example_count.zero?
11
11
 
12
12
  stats = TestNotifier::Stats.new(:spec, {
13
- :total => example_count,
14
- :fail => failure_count,
15
- :pending => pending_count,
16
- :error => nil
13
+ :count => example_count,
14
+ :failures => failure_count,
15
+ :pending => pending_count,
16
+ :errors => nil
17
17
  })
18
18
 
19
- TestNotifier.notify(:status => stats.status, :message => stats.message) if example_count > 0
19
+ TestNotifier.notify(:status => stats.status, :message => stats.message)
20
20
  end
21
21
  end
@@ -13,7 +13,13 @@ class Test::Unit::UI::Console::TestRunner
13
13
  return if tests.to_i.zero?
14
14
 
15
15
 
16
- stats = TestNotifier::Stats.new(:test_unit, :total => tests, :assertions => assertions, :fail => failures, :error => errors)
16
+ stats = TestNotifier::Stats.new(:test_unit, {
17
+ :count => tests,
18
+ :assertions => assertions,
19
+ :failures => failures,
20
+ :errors => errors
21
+ })
22
+
17
23
  TestNotifier.notify(:status => stats.status, :message => stats.message)
18
24
  rescue
19
25
  end
@@ -19,7 +19,7 @@ module TestNotifier
19
19
 
20
20
  private
21
21
  def normalize(options)
22
- [:total, :success, :fail, :pending, :errors, :assertions].inject({}) do |buffer, key|
22
+ [:count, :success, :failures, :pending, :errors, :assertions].inject({}) do |buffer, key|
23
23
  buffer[key] = options[key].to_i
24
24
  buffer
25
25
  end
@@ -28,7 +28,7 @@ module TestNotifier
28
28
  def status_for_test_unit
29
29
  if options[:errors].nonzero?
30
30
  :error
31
- elsif options[:fail].nonzero?
31
+ elsif options[:failures].nonzero?
32
32
  :fail
33
33
  else
34
34
  :success
@@ -38,7 +38,7 @@ module TestNotifier
38
38
  def status_for_rspec
39
39
  if options[:errors].nonzero?
40
40
  :error
41
- elsif options[:fail].nonzero?
41
+ elsif options[:failures].nonzero?
42
42
  :fail
43
43
  else
44
44
  :success
@@ -46,7 +46,7 @@ module TestNotifier
46
46
  end
47
47
 
48
48
  def status_for_spec
49
- if options[:fail].nonzero?
49
+ if options[:failures].nonzero?
50
50
  :fail
51
51
  else
52
52
  :success
@@ -54,12 +54,11 @@ module TestNotifier
54
54
  end
55
55
 
56
56
  def message_for_rspec
57
- options[:success] = options[:total] - options[:fail]
58
- options[:fail] = options[:fail] - options[:errors]
57
+ options[:success] = options[:count] - (options[:failures] + options[:errors])
59
58
 
60
59
  text = []
61
- text << "#{options[:total]} " + pluralize(options[:total], "example")
62
- text << "#{options[:fail]} failed" unless options[:fail].zero?
60
+ text << "#{options[:count]} " + pluralize(options[:count], "example")
61
+ text << "#{options[:failures]} failed" unless options[:failures].zero?
63
62
  text << "#{options[:pending]} pending" unless options[:pending].zero?
64
63
  text << "#{options[:errors]} " + pluralize(options[:errors], "error") unless options[:errors].zero?
65
64
  text.join(", ")
@@ -67,17 +66,17 @@ module TestNotifier
67
66
 
68
67
  def message_for_spec
69
68
  text = []
70
- text << "#{options[:total]} " + pluralize(options[:total], "example")
71
- text << "#{options[:fail]} failed" unless options[:fail].zero?
69
+ text << "#{options[:count]} " + pluralize(options[:count], "example")
70
+ text << "#{options[:failures]} failed" unless options[:failures].zero?
72
71
  text << "#{options[:pending]} pending" unless options[:pending].zero?
73
72
  text.join(", ")
74
73
  end
75
74
 
76
75
  def message_for_test_unit
77
76
  text = []
78
- text << "#{options[:total]} " + pluralize(options[:total], "test")
77
+ text << "#{options[:count]} " + pluralize(options[:count], "test")
79
78
  text << "#{options[:assertions]} " + pluralize(options[:assertions], "assertion")
80
- text << "#{options[:fail]} failed" unless options[:fail].zero?
79
+ text << "#{options[:failures]} failed" unless options[:failures].zero?
81
80
  text << "#{options[:errors]} " + pluralize(options[:errors], "error") unless options[:errors].zero?
82
81
  text.join(", ")
83
82
  end
@@ -2,7 +2,7 @@ module TestNotifier
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- PATCH = 2
5
+ PATCH = 3
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
data/test/stats_test.rb CHANGED
@@ -6,28 +6,28 @@ class TestNotifier::Stats::RSpecTest < Test::Unit::TestCase
6
6
  end
7
7
 
8
8
  test "success message" do
9
- @stats.options = { :total => 10 }
9
+ @stats.options = { :count => 10 }
10
10
  assert_equal "10 examples", @stats.message
11
11
  end
12
12
 
13
13
  test "message with failing examples" do
14
- @stats.options = { :total => 10, :fail => 5 }
14
+ @stats.options = { :count => 10, :failures => 5 }
15
15
  assert_equal "10 examples, 5 failed", @stats.message
16
16
  end
17
17
 
18
18
  test "message with pending examples" do
19
- @stats.options = { :total => 10, :pending => 5 }
19
+ @stats.options = { :count => 10, :pending => 5 }
20
20
  assert_equal "10 examples, 5 pending", @stats.message
21
21
  end
22
22
 
23
23
  test "message with error examples" do
24
- @stats.options = { :total => 10, :fail => 5, :errors => 5 }
25
- assert_equal "10 examples, 5 errors", @stats.message
24
+ @stats.options = { :count => 10, :failures => 5, :errors => 5 }
25
+ assert_equal "10 examples, 5 failed, 5 errors", @stats.message
26
26
  end
27
27
 
28
28
  test "message with all types" do
29
- @stats.options = { :total => 6, :fail => 3, :errors => 2, :pending => 3 }
30
- assert_equal "6 examples, 1 failed, 3 pending, 2 errors", @stats.message
29
+ @stats.options = { :count => 6, :failures => 3, :errors => 2, :pending => 3 }
30
+ assert_equal "6 examples, 3 failed, 3 pending, 2 errors", @stats.message
31
31
  end
32
32
  end
33
33
 
@@ -37,22 +37,22 @@ class TestNotifier::Stats::SpecTest < Test::Unit::TestCase
37
37
  end
38
38
 
39
39
  test "success message" do
40
- @stats.options = { :total => 10 }
40
+ @stats.options = { :count => 10 }
41
41
  assert_equal "10 examples", @stats.message
42
42
  end
43
43
 
44
44
  test "message with failing examples" do
45
- @stats.options = { :total => 10, :fail => 5 }
45
+ @stats.options = { :count => 10, :failures => 5 }
46
46
  assert_equal "10 examples, 5 failed", @stats.message
47
47
  end
48
48
 
49
49
  test "message with pending examples" do
50
- @stats.options = { :total => 10, :pending => 5 }
50
+ @stats.options = { :count => 10, :pending => 5 }
51
51
  assert_equal "10 examples, 5 pending", @stats.message
52
52
  end
53
53
 
54
54
  test "message with all types" do
55
- @stats.options = { :total => 6, :fail => 2, :pending => 3 }
55
+ @stats.options = { :count => 6, :failures => 2, :pending => 3 }
56
56
  assert_equal "6 examples, 2 failed, 3 pending", @stats.message
57
57
  end
58
58
  end
@@ -63,22 +63,22 @@ class TestNotifier::Stats::TestUnitTest < Test::Unit::TestCase
63
63
  end
64
64
 
65
65
  test "success message" do
66
- @stats.options = { :total => 10, :assertions => 20 }
66
+ @stats.options = { :count => 10, :assertions => 20 }
67
67
  assert_equal "10 tests, 20 assertions", @stats.message
68
68
  end
69
69
 
70
70
  test "message with failing examples" do
71
- @stats.options = { :total => 10, :assertions => 20, :fail => 5 }
71
+ @stats.options = { :count => 10, :assertions => 20, :failures => 5 }
72
72
  assert_equal "10 tests, 20 assertions, 5 failed", @stats.message
73
73
  end
74
74
 
75
75
  test "message with error examples" do
76
- @stats.options = { :total => 10, :assertions => 20, :errors => 5 }
76
+ @stats.options = { :count => 10, :assertions => 20, :errors => 5 }
77
77
  assert_equal "10 tests, 20 assertions, 5 errors", @stats.message
78
78
  end
79
79
 
80
80
  test "message with all types" do
81
- @stats.options = { :total => 6, :fail => 2, :errors => 3, :assertions => 20 }
81
+ @stats.options = { :count => 6, :failures => 2, :errors => 3, :assertions => 20 }
82
82
  assert_equal "6 tests, 20 assertions, 2 failed, 3 errors", @stats.message
83
83
  end
84
84
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_notifier
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nando Vieira
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-27 00:00:00 -03:00
18
+ date: 2010-08-30 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies: []
21
21