test_notifier 0.3.1 → 0.3.2
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.
@@ -9,23 +9,19 @@ Autotest.add_hook :ran_command do |at|
|
|
9
9
|
|
10
10
|
if rspec_matches
|
11
11
|
_, examples, failures, _, pending = *rspec_matches
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
TestNotifier.notify(:status => status, :message => message) unless examples.to_i.zero?
|
12
|
+
|
13
|
+
stats = TestNotifier::Stats.new(:spec, :total => examples, :fail => failures, :pending => pending)
|
14
|
+
TestNotifier.notify(:status => stats.status, :message => stats.message) unless examples.to_i.zero?
|
16
15
|
elsif test_unit_matches
|
17
16
|
_, tests, assertions, failures, errors = *test_unit_matches
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
message = "#{tests} tests, #{assertions} assertions, #{failures} failures, #{errors} errors"
|
28
|
-
TestNotifier.notify(:status => status, :message => message) unless tests.to_i.zero?
|
18
|
+
stats = TestNotifier::Stats.new(:test_unit, {
|
19
|
+
:total => tests,
|
20
|
+
:assertions => assertions,
|
21
|
+
:fail => failures,
|
22
|
+
:errors => errors
|
23
|
+
})
|
24
|
+
TestNotifier.notify(:status => stats.status, :message => stats.message) unless tests.to_i.zero?
|
29
25
|
end
|
30
26
|
rescue
|
31
27
|
end
|
@@ -13,7 +13,7 @@ class RSpec::Core::Formatters::BaseTextFormatter
|
|
13
13
|
:total => example_count,
|
14
14
|
:fail => failure_count,
|
15
15
|
:pending => pending_count,
|
16
|
-
:
|
16
|
+
:errors => examples.reject {|e| e.instance_variable_get("@exception").nil?}.count
|
17
17
|
})
|
18
18
|
|
19
19
|
TestNotifier.notify(:status => stats.status, :message => stats.message)
|
data/lib/test_notifier/stats.rb
CHANGED
@@ -19,14 +19,14 @@ module TestNotifier
|
|
19
19
|
|
20
20
|
private
|
21
21
|
def normalize(options)
|
22
|
-
[:total, :success, :fail, :pending, :
|
22
|
+
[:total, :success, :fail, :pending, :errors, :assertions].inject({}) do |buffer, key|
|
23
23
|
buffer[key] = options[key].to_i
|
24
24
|
buffer
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def status_for_test_unit
|
29
|
-
if options[:
|
29
|
+
if options[:errors].nonzero?
|
30
30
|
:error
|
31
31
|
elsif options[:fail].nonzero?
|
32
32
|
:fail
|
@@ -36,7 +36,7 @@ module TestNotifier
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def status_for_rspec
|
39
|
-
if options[:
|
39
|
+
if options[:errors].nonzero?
|
40
40
|
:error
|
41
41
|
elsif options[:fail].nonzero?
|
42
42
|
:fail
|
@@ -55,13 +55,13 @@ module TestNotifier
|
|
55
55
|
|
56
56
|
def message_for_rspec
|
57
57
|
options[:success] = options[:total] - options[:fail]
|
58
|
-
options[:fail] = options[:fail] - options[:
|
58
|
+
options[:fail] = options[:fail] - options[:errors]
|
59
59
|
|
60
60
|
text = []
|
61
61
|
text << "#{options[:total]} " + pluralize(options[:total], "example")
|
62
62
|
text << "#{options[:fail]} failed" unless options[:fail].zero?
|
63
63
|
text << "#{options[:pending]} pending" unless options[:pending].zero?
|
64
|
-
text << "#{options[:
|
64
|
+
text << "#{options[:errors]} " + pluralize(options[:errors], "error") unless options[:errors].zero?
|
65
65
|
text.join(", ")
|
66
66
|
end
|
67
67
|
|
@@ -78,7 +78,7 @@ module TestNotifier
|
|
78
78
|
text << "#{options[:total]} " + pluralize(options[:total], "test")
|
79
79
|
text << "#{options[:assertions]} " + pluralize(options[:assertions], "assertion")
|
80
80
|
text << "#{options[:fail]} failed" unless options[:fail].zero?
|
81
|
-
text << "#{options[:
|
81
|
+
text << "#{options[:errors]} " + pluralize(options[:errors], "error") unless options[:errors].zero?
|
82
82
|
text.join(", ")
|
83
83
|
end
|
84
84
|
|
data/test/stats_test.rb
CHANGED
@@ -21,12 +21,12 @@ class TestNotifier::Stats::RSpecTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
test "message with error examples" do
|
24
|
-
@stats.options = { :total => 10, :fail => 5, :
|
24
|
+
@stats.options = { :total => 10, :fail => 5, :errors => 5 }
|
25
25
|
assert_equal "10 examples, 5 errors", @stats.message
|
26
26
|
end
|
27
27
|
|
28
28
|
test "message with all types" do
|
29
|
-
@stats.options = { :total => 6, :fail => 3, :
|
29
|
+
@stats.options = { :total => 6, :fail => 3, :errors => 2, :pending => 3 }
|
30
30
|
assert_equal "6 examples, 1 failed, 3 pending, 2 errors", @stats.message
|
31
31
|
end
|
32
32
|
end
|
@@ -73,12 +73,12 @@ class TestNotifier::Stats::TestUnitTest < Test::Unit::TestCase
|
|
73
73
|
end
|
74
74
|
|
75
75
|
test "message with error examples" do
|
76
|
-
@stats.options = { :total => 10, :assertions => 20, :
|
76
|
+
@stats.options = { :total => 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, :
|
81
|
+
@stats.options = { :total => 6, :fail => 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:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nando Vieira
|