test_notifier 0.3.2 → 0.3.3
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/lib/test_notifier/runner/autotest.rb +10 -4
- data/lib/test_notifier/runner/rspec.rb +12 -4
- data/lib/test_notifier/runner/spec.rb +5 -5
- data/lib/test_notifier/runner/test_unit.rb +7 -1
- data/lib/test_notifier/stats.rb +11 -12
- data/lib/test_notifier/version.rb +1 -1
- data/test/stats_test.rb +15 -15
- metadata +4 -4
@@ -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,
|
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
|
-
:
|
24
|
+
:count => tests,
|
20
25
|
:assertions => assertions,
|
21
|
-
:
|
22
|
-
: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
|
-
:
|
14
|
-
:
|
15
|
-
:pending
|
16
|
-
:errors
|
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
|
-
:
|
14
|
-
:
|
15
|
-
:pending
|
16
|
-
:
|
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)
|
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,
|
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
|
data/lib/test_notifier/stats.rb
CHANGED
@@ -19,7 +19,7 @@ module TestNotifier
|
|
19
19
|
|
20
20
|
private
|
21
21
|
def normalize(options)
|
22
|
-
[:
|
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[:
|
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[:
|
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[:
|
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[:
|
58
|
-
options[:fail] = options[:fail] - options[:errors]
|
57
|
+
options[:success] = options[:count] - (options[:failures] + options[:errors])
|
59
58
|
|
60
59
|
text = []
|
61
|
-
text << "#{options[:
|
62
|
-
text << "#{options[:
|
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[:
|
71
|
-
text << "#{options[:
|
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[:
|
77
|
+
text << "#{options[:count]} " + pluralize(options[:count], "test")
|
79
78
|
text << "#{options[:assertions]} " + pluralize(options[:assertions], "assertion")
|
80
|
-
text << "#{options[:
|
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
|
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 = { :
|
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 = { :
|
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 = { :
|
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 = { :
|
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 = { :
|
30
|
-
assert_equal "6 examples,
|
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 = { :
|
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 = { :
|
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 = { :
|
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 = { :
|
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 = { :
|
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 = { :
|
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 = { :
|
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 = { :
|
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:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
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-
|
18
|
+
date: 2010-08-30 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|