rspec_junit_formatter 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +6 -4
- data/lib/rspec_junit_formatter.rb +63 -6
- data/lib/rspec_junit_formatter/rspec2.rb +45 -0
- data/lib/rspec_junit_formatter/rspec3.rb +65 -0
- metadata +66 -32
- metadata.gz.sig +0 -0
- data/lib/rspec/core/formatters/j_unit_formatter.rb +0 -55
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4ff821525517ff9e64733fd500e22399577252b5
|
4
|
+
data.tar.gz: d988af0bd85a6a198d314597df587239a22e3c94
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 09bda5d34cd82f1ddd6c31c61a3c4249d23ef842352ad799968ac826ad498a099c561beccdd3794f3c2ebbab52582d81781beb865f7276d0d853ebf0a062727f
|
7
|
+
data.tar.gz: 484ad5700266c03add749dc3a87b5805e486f51f21e965d4d11764cb312a32e66fad92ee28a6ee55eda1cb01a52f9e68588e369df5f1fe2b3ac4a259d492fee8
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# RSpec JUnit Formatter
|
2
2
|
|
3
|
-
[
|
3
|
+
[![Build results](http://img.shields.io/travis/sj26/rspec_junit_formatter.svg)](https://travis-ci.org/sj26/rspec_junit_formatter)
|
4
4
|
|
5
|
-
|
5
|
+
[RSpec][rspec] 2 & 3 results that [Jenkins][jenkins] can read. Probably a few other CI servers, too.
|
6
|
+
|
7
|
+
Inspired by the work of [Diego Souza][dgvncsz0f] on [RSpec Formatters][dgvncsz0f/rspec_formatters] after frustration with [CI Reporter][ci_reporter].
|
6
8
|
|
7
9
|
## Usage
|
8
10
|
|
@@ -38,8 +40,8 @@ The MIT License, see [LICENSE][license].
|
|
38
40
|
|
39
41
|
[rspec]: http://rspec.info/
|
40
42
|
[jenkins]: http://jenkins-ci.org/
|
41
|
-
[
|
42
|
-
[
|
43
|
+
[dgvncsz0f]: https://github.com/dgvncsz0f
|
44
|
+
[dgvncsz0f/rspec_formatters]: https://github.com/dgvncsz0f/rspec_formatters
|
43
45
|
[ci_reporter]: http://caldersphere.rubyforge.org/ci_reporter/
|
44
46
|
[bundler]: http://gembundler.com/
|
45
47
|
[fuubar]: http://jeffkreeftmeijer.com/2010/fuubar-the-instafailing-rspec-progress-bar-formatter/
|
@@ -1,8 +1,65 @@
|
|
1
|
-
require
|
2
|
-
require 'rspec'
|
1
|
+
require "time"
|
3
2
|
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "builder"
|
4
|
+
require "rspec"
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
require "rspec/core/formatters/base_formatter"
|
7
|
+
|
8
|
+
# Dumps rspec results as a JUnit XML file.
|
9
|
+
# Based on XML schema: http://windyroad.org/dl/Open%20Source/JUnit.xsd
|
10
|
+
class RSpecJUnitFormatter < RSpec::Core::Formatters::BaseFormatter
|
11
|
+
# rspec 2 and 3 implements are in separate files.
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def xml
|
16
|
+
@xml ||= Builder::XmlMarkup.new target: output, indent: 2
|
17
|
+
end
|
18
|
+
|
19
|
+
def xml_dump
|
20
|
+
xml.instruct!
|
21
|
+
xml.testsuite name: "rspec", tests: example_count, failures: failure_count, errors: 0, time: "%.6f" % duration, timestamp: started.iso8601 do
|
22
|
+
xml.properties
|
23
|
+
xml_dump_examples
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def xml_dump_examples
|
28
|
+
examples.each do |example|
|
29
|
+
send :"xml_dump_#{result_of(example)}", example
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def xml_dump_passed(example)
|
34
|
+
xml_dump_example(example)
|
35
|
+
end
|
36
|
+
|
37
|
+
def xml_dump_pending(example)
|
38
|
+
xml_dump_example(example) do
|
39
|
+
xml.skipped
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def xml_dump_failed(example)
|
44
|
+
exception = exception_for(example)
|
45
|
+
backtrace = formatted_backtrace_for(example)
|
46
|
+
|
47
|
+
xml_dump_example(example) do
|
48
|
+
xml.failure message: exception.to_s, type: exception.class.name do
|
49
|
+
xml.cdata! "#{exception.message}\n#{backtrace.join "\n"}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def xml_dump_example(example, &block)
|
55
|
+
xml.testcase classname: classname_for(example), name: description_for(example), time: "%.6f" % duration_for(example), &block
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
RspecJunitFormatter = RSpecJUnitFormatter
|
60
|
+
|
61
|
+
if RSpec::Version::STRING.start_with? "3."
|
62
|
+
require "rspec_junit_formatter/rspec3"
|
63
|
+
else RSpec::Version::STRING.start_with? "2."
|
64
|
+
require "rspec_junit_formatter/rspec2"
|
65
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class RSpecJUnitFormatter < RSpec::Core::Formatters::BaseFormatter
|
2
|
+
attr_reader :started
|
3
|
+
|
4
|
+
def start(example_count)
|
5
|
+
@started = Time.now
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def dump_summary(duration, example_count, failure_count, pending_count)
|
10
|
+
super
|
11
|
+
xml_dump
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def xml_dump_examples
|
17
|
+
examples.each do |example|
|
18
|
+
send :"xml_dump_#{example.execution_result[:status]}", example
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def result_of(example)
|
23
|
+
example.execution_result[:status]
|
24
|
+
end
|
25
|
+
|
26
|
+
def classname_for(example)
|
27
|
+
example.file_path.sub(%r{\.[^/.]+\Z}, "").gsub("/", ".").gsub(/\A\.+|\.+\Z/, "")
|
28
|
+
end
|
29
|
+
|
30
|
+
def duration_for(example)
|
31
|
+
example.execution_result[:run_time]
|
32
|
+
end
|
33
|
+
|
34
|
+
def description_for(example)
|
35
|
+
example.full_description
|
36
|
+
end
|
37
|
+
|
38
|
+
def exception_for(example)
|
39
|
+
example.execution_result[:exception]
|
40
|
+
end
|
41
|
+
|
42
|
+
def formatted_backtrace_for(example)
|
43
|
+
format_backtrace exception_for(example).backtrace, example
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
class RSpecJUnitFormatter < RSpec::Core::Formatters::BaseFormatter
|
2
|
+
RSpec::Core::Formatters.register self,
|
3
|
+
:start,
|
4
|
+
:stop,
|
5
|
+
:dump_summary
|
6
|
+
|
7
|
+
def start(notification)
|
8
|
+
@start_notification = notification
|
9
|
+
@started = Time.now
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def stop(notification)
|
14
|
+
@examples_notification = notification
|
15
|
+
end
|
16
|
+
|
17
|
+
def dump_summary(notification)
|
18
|
+
@summary_notification = notification
|
19
|
+
xml_dump
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :started
|
25
|
+
|
26
|
+
def example_count
|
27
|
+
@summary_notification.examples.count
|
28
|
+
end
|
29
|
+
|
30
|
+
def failure_count
|
31
|
+
@summary_notification.failed_examples.count
|
32
|
+
end
|
33
|
+
|
34
|
+
def duration
|
35
|
+
@summary_notification.duration
|
36
|
+
end
|
37
|
+
|
38
|
+
def examples
|
39
|
+
@examples_notification.notifications
|
40
|
+
end
|
41
|
+
|
42
|
+
def result_of(notification)
|
43
|
+
notification.example.execution_result[:status]
|
44
|
+
end
|
45
|
+
|
46
|
+
def classname_for(notification)
|
47
|
+
notification.example.file_path.sub(%r{\.[^/]*\Z}, "").gsub("/", ".").gsub(%r{\A\.+|\.+\Z}, "")
|
48
|
+
end
|
49
|
+
|
50
|
+
def duration_for(notification)
|
51
|
+
notification.example.execution_result[:run_time]
|
52
|
+
end
|
53
|
+
|
54
|
+
def description_for(notification)
|
55
|
+
notification.example.full_description
|
56
|
+
end
|
57
|
+
|
58
|
+
def exception_for(notification)
|
59
|
+
notification.example.execution_result[:exception]
|
60
|
+
end
|
61
|
+
|
62
|
+
def formatted_backtrace_for(notification)
|
63
|
+
backtrace = notification.formatted_backtrace
|
64
|
+
end
|
65
|
+
end
|
metadata
CHANGED
@@ -1,96 +1,130 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_junit_formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.1.6
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Samuel Cochran
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
|
-
cert_chain:
|
12
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDKDCCAhCgAwIBAgIBAjANBgkqhkiG9w0BAQUFADA6MQ0wCwYDVQQDDARzajI2
|
14
|
+
MRQwEgYKCZImiZPyLGQBGRYEc2oyNjETMBEGCgmSJomT8ixkARkWA2NvbTAeFw0x
|
15
|
+
NDAzMTUwNDM2MTZaFw0xNTAzMTUwNDM2MTZaMDoxDTALBgNVBAMMBHNqMjYxFDAS
|
16
|
+
BgoJkiaJk/IsZAEZFgRzajI2MRMwEQYKCZImiZPyLGQBGRYDY29tMIIBIjANBgkq
|
17
|
+
hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsr60Eo/ttCk8GMTMFiPr3GoYMIMFvLak
|
18
|
+
xSmTk9YGCB6UiEePB4THSSA5w6IPyeaCF/nWkDp3/BAam0eZMWG1IzYQB23TqIM0
|
19
|
+
1xzcNRvFsn0aQoQ00k+sj+G83j3T5OOV5OZIlu8xAChMkQmiPd1NXc6uFv+Iacz7
|
20
|
+
kj+CMsI9YUFdNoU09QY0b+u+Rb6wDYdpyvN60YC30h0h1MeYbvYZJx/iZK4XY5zu
|
21
|
+
4O/FL2ChjL2CPCpLZW55ShYyrzphWJwLOJe+FJ/ZBl6YXwrzQM9HKnt4titSNvyU
|
22
|
+
KzE3L63A3PZvExzLrN9u09kuWLLJfXB2sGOlw3n9t72rJiuBr3/OQQIDAQABozkw
|
23
|
+
NzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU99dfRjEKFyczTeIz
|
24
|
+
m3ZsDWrNC80wDQYJKoZIhvcNAQEFBQADggEBAFVYjABGprFHcomF60jQZojPyBVj
|
25
|
+
IBUmAKQ2UEserCwV8GbzxKn9/C+cqO109m1KckeGvFDSvUToBUIEzj5xKNMLJCYJ
|
26
|
+
xjH30ex7X0LDgqI4z4Z9eXiIR61d9haKEDpqVRKrERMcf4HAyvQoNmYtVTesVNJr
|
27
|
+
rWOeOPhl1Is+NdYcm1c99Y1ltcstn762ROxVCFk9c6Xe9mrDgB5oBW+LKOY2YCjD
|
28
|
+
HLacq0o6ejD7AFG3HPAVFeYEnrwCYd6siMnzpVrt3pHfZJxsuhbNnteASNcnk9Uk
|
29
|
+
YIxHmqJUGGnmqwuBfXe8LZHC5ETJLuZlzO2odzNueQlhukD4wdNa/r4pD1o=
|
30
|
+
-----END CERTIFICATE-----
|
31
|
+
date: 2014-06-04 00:00:00.000000000 Z
|
13
32
|
dependencies:
|
14
33
|
- !ruby/object:Gem::Dependency
|
15
34
|
name: rspec
|
16
|
-
type: :runtime
|
17
35
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
36
|
requirements:
|
20
|
-
- -
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2'
|
40
|
+
- - "<"
|
21
41
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
42
|
+
version: '4'
|
43
|
+
type: :runtime
|
23
44
|
prerelease: false
|
24
45
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
46
|
requirements:
|
27
|
-
- -
|
47
|
+
- - ">="
|
28
48
|
- !ruby/object:Gem::Version
|
29
|
-
version: '2
|
49
|
+
version: '2'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '4'
|
30
53
|
- !ruby/object:Gem::Dependency
|
31
54
|
name: rspec-core
|
32
|
-
type: :runtime
|
33
55
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
56
|
requirements:
|
36
|
-
- -
|
57
|
+
- - "!="
|
37
58
|
- !ruby/object:Gem::Version
|
38
59
|
version: 2.12.0
|
60
|
+
type: :runtime
|
39
61
|
prerelease: false
|
40
62
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
63
|
requirements:
|
43
|
-
- -
|
64
|
+
- - "!="
|
44
65
|
- !ruby/object:Gem::Version
|
45
66
|
version: 2.12.0
|
46
67
|
- !ruby/object:Gem::Dependency
|
47
68
|
name: builder
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "<"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '4'
|
48
74
|
type: :runtime
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "<"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '4'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: nokogiri
|
49
83
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
84
|
requirements:
|
52
|
-
- -
|
85
|
+
- - "~>"
|
53
86
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
87
|
+
version: '1.6'
|
88
|
+
type: :development
|
55
89
|
prerelease: false
|
56
90
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
91
|
requirements:
|
59
|
-
- -
|
92
|
+
- - "~>"
|
60
93
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
94
|
+
version: '1.6'
|
62
95
|
description: RSpec results that Hudson can read.
|
63
96
|
email: sj26@sj26.com
|
64
97
|
executables: []
|
65
98
|
extensions: []
|
66
99
|
extra_rdoc_files: []
|
67
100
|
files:
|
68
|
-
- lib/rspec/core/formatters/j_unit_formatter.rb
|
69
|
-
- lib/rspec_junit_formatter.rb
|
70
|
-
- README.md
|
71
101
|
- LICENSE
|
102
|
+
- README.md
|
103
|
+
- lib/rspec_junit_formatter.rb
|
104
|
+
- lib/rspec_junit_formatter/rspec2.rb
|
105
|
+
- lib/rspec_junit_formatter/rspec3.rb
|
72
106
|
homepage: http://github.com/sj26/rspec_junit_formatter
|
73
|
-
licenses:
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
74
110
|
post_install_message:
|
75
111
|
rdoc_options: []
|
76
112
|
require_paths:
|
77
113
|
- lib
|
78
114
|
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
115
|
requirements:
|
81
|
-
- -
|
116
|
+
- - ">="
|
82
117
|
- !ruby/object:Gem::Version
|
83
118
|
version: '0'
|
84
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
120
|
requirements:
|
87
|
-
- -
|
121
|
+
- - ">="
|
88
122
|
- !ruby/object:Gem::Version
|
89
123
|
version: 1.3.6
|
90
124
|
requirements: []
|
91
125
|
rubyforge_project:
|
92
|
-
rubygems_version:
|
126
|
+
rubygems_version: 2.2.2
|
93
127
|
signing_key:
|
94
|
-
specification_version:
|
128
|
+
specification_version: 4
|
95
129
|
summary: RSpec JUnit XML formatter
|
96
130
|
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'time'
|
2
|
-
|
3
|
-
# Dumps rspec results as a JUnit XML file.
|
4
|
-
# Based on XML schema: http://windyroad.org/dl/Open%20Source/JUnit.xsd
|
5
|
-
class RSpec::Core::Formatters::JUnitFormatter < RSpec::Core::Formatters::BaseFormatter
|
6
|
-
def xml
|
7
|
-
@xml ||= Builder::XmlMarkup.new :target => output, :indent => 2
|
8
|
-
end
|
9
|
-
|
10
|
-
def start example_count
|
11
|
-
@start = Time.now
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
def dump_summary duration, example_count, failure_count, pending_count
|
16
|
-
super
|
17
|
-
|
18
|
-
xml.instruct!
|
19
|
-
xml.testsuite :tests => example_count, :failures => failure_count, :errors => 0, :time => '%.6f' % duration, :timestamp => @start.iso8601 do
|
20
|
-
xml.properties
|
21
|
-
examples.each do |example|
|
22
|
-
send :"dump_summary_example_#{example.execution_result[:status]}", example
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def xml_example example, &block
|
28
|
-
xml.testcase :classname => example_classname(example), :name => example.full_description, :time => '%.6f' % example.execution_result[:run_time], &block
|
29
|
-
end
|
30
|
-
|
31
|
-
def dump_summary_example_passed example
|
32
|
-
xml_example example
|
33
|
-
end
|
34
|
-
|
35
|
-
def dump_summary_example_pending example
|
36
|
-
xml_example example do
|
37
|
-
xml.skipped
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def dump_summary_example_failed example
|
42
|
-
exception = example.execution_result[:exception]
|
43
|
-
backtrace = format_backtrace exception.backtrace, example
|
44
|
-
|
45
|
-
xml_example example do
|
46
|
-
xml.failure :message => exception.to_s, :type => exception.class.name do
|
47
|
-
xml.cdata! "#{exception.message}\n#{backtrace.join "\n"}"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def example_classname example
|
53
|
-
example.file_path.sub(%r{\.[^/]*\Z}, "").gsub("/", ".").gsub(%r{\A\.+|\.+\Z}, "")
|
54
|
-
end
|
55
|
-
end
|