rspec_junit_formatter 0.2.3 → 0.3.0.pre

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aba33189eb6723f651a6d245f76fbd9c875339d8
4
- data.tar.gz: 9de71e43b41fd5772143206cf51657380790042d
3
+ metadata.gz: f06d768eaf9e411ad68a32229073dc7aa32917e1
4
+ data.tar.gz: 7d90c8e0eb6e9b786c0a7057f2f6b1645803f685
5
5
  SHA512:
6
- metadata.gz: 53f6734e3e839de30f60d22ed80371a458927796e46ea6b2ec2b2d8a8a9e00ef7ffd3d5dd663151de5be1aed33dd2de0e716bc79c1a84cb757292a7f943469d5
7
- data.tar.gz: 50d33e7d36886ea36679b02871771c482e2d3aacd7fd94c4accb08e49c4858db2857ab90f1e5e215e2b78769a50c861e228d23a1177b863ae9d2879b03a39796
6
+ metadata.gz: 84ffd05878f6574d9d3e20ed9317432dbfb8f87894d5aa87264048ee8e6cd233b1f61dd28e1b1f5c9b614d7b89bc6e2627855c2cc17fd742492b2c8a2dc3946c
7
+ data.tar.gz: 3f9e1f4d8d3cad02103a3cb4a43446ebecc19d207ad891360d997efc2090adf9e82fa67b8db18913d4f74fd20df3855b29fa430aea3288f08b0a69b2c0df7465
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # RSpec JUnit Formatter
2
2
 
3
- [![Build results](http://img.shields.io/travis/sj26/rspec_junit_formatter.svg)](https://travis-ci.org/sj26/rspec_junit_formatter)
4
- [![Gem version](http://img.shields.io/gem/v/rspec_junit_formatter.svg)](https://rubygems.org/gem/rspec_junit_formatter)
3
+ [![Build results](http://img.shields.io/travis/sj26/rspec_junit_formatter/master.svg)](https://travis-ci.org/sj26/rspec_junit_formatter)
4
+ [![Gem version](http://img.shields.io/gem/v/rspec_junit_formatter.svg)](https://rubygems.org/gems/rspec_junit_formatter)
5
5
 
6
- [RSpec][rspec] 2 & 3 results that [Jenkins][jenkins] can read. Probably a few other CI servers, too.
6
+ [RSpec][rspec] 2 & 3 results that [Jenkins][jenkins] can read. Probably a few other CI services, too.
7
7
 
8
8
  Inspired by the work of [Diego Souza][dgvncsz0f] on [RSpec Formatters][dgvncsz0f/rspec_formatters] after frustration with [CI Reporter][ci_reporter].
9
9
 
@@ -11,35 +11,55 @@ Inspired by the work of [Diego Souza][dgvncsz0f] on [RSpec Formatters][dgvncsz0f
11
11
 
12
12
  Install the gem:
13
13
 
14
- gem install rspec_junit_formatter
14
+ ```sh
15
+ gem install rspec_junit_formatter
16
+ ```
15
17
 
16
18
  Use it:
17
19
 
18
- rspec --format RspecJunitFormatter --out rspec.xml
20
+ ```sh
21
+ rspec --format RspecJunitFormatter --out rspec.xml
22
+ ```
19
23
 
20
- You'll get an XML file with your results in it.
24
+ You'll get an XML file `rspec.xml` with your results in it.
21
25
 
22
- ## More Permanent Usage
26
+ You can use it in combination with other [formatters][rspec-formatters], too:
27
+
28
+ ```sh
29
+ rspec --format progress --format RspecJunitFormatter --out rspec.xml
30
+ ```
31
+
32
+ ### Using in your project with Bundler
23
33
 
24
34
  Add it to your Gemfile if you're using [Bundler][bundler]. Put it in the same groups as rspec.
25
35
 
26
- In your .rspec, usually alongside another formatter, add:
36
+ ```ruby
37
+ group :test do
38
+ gem "rspec"
39
+ gem "rspec_junit_formatter"
40
+ end
41
+ ```
27
42
 
28
- --format RspecJunitFormatter
29
- --out rspec.xml
43
+ Put the same arguments as the commands above in [your `.rspec`][rspec-file]:
30
44
 
31
- I use it with the excellent [Fuubar formatter][fuubar].
45
+ ```
46
+ --format RspecJunitFormatter
47
+ --out rspec.xml
48
+ ```
32
49
 
33
50
  ## Roadmap
34
51
 
35
- * It would be nice to split things up into individual test suites, although would this correspond to example groups? The subject? The spec file? Not sure yet.
36
- * This would sit nicely in rspec-core, and has been designed to do so.
52
+ * It would be nice to split things up into individual test suites, although
53
+ would this correspond to example groups? The subject? The spec file? Not
54
+ sure yet.
37
55
 
38
56
  ## License
39
57
 
40
58
  The MIT License, see [LICENSE][license].
41
59
 
42
60
  [rspec]: http://rspec.info/
61
+ [rspec-formatters]: https://relishapp.com/rspec/rspec-core/v/3-6/docs/formatters
62
+ [rspec-file]: https://relishapp.com/rspec/rspec-core/v/3-6/docs/configuration/read-command-line-configuration-options-from-files
43
63
  [jenkins]: http://jenkins-ci.org/
44
64
  [dgvncsz0f]: https://github.com/dgvncsz0f
45
65
  [dgvncsz0f/rspec_formatters]: https://github.com/dgvncsz0f/rspec_formatters
@@ -1,5 +1,4 @@
1
1
  require "time"
2
- require "builder"
3
2
 
4
3
  require "rspec/core"
5
4
  require "rspec/core/formatters/base_formatter"
@@ -11,17 +10,24 @@ class RSpecJUnitFormatter < RSpec::Core::Formatters::BaseFormatter
11
10
 
12
11
  private
13
12
 
14
- def xml
15
- @xml ||= Builder::XmlMarkup.new target: output, indent: 2
16
- end
17
-
18
13
  def xml_dump
19
- xml.instruct!
20
- xml.testsuite name: "rspec#{ENV['TEST_ENV_NUMBER']}", tests: example_count, failures: failure_count, errors: 0, time: "%.6f" % duration, timestamp: started.iso8601 do
21
- xml.comment! "Randomized with seed #{RSpec.configuration.seed}"
22
- xml.properties
23
- xml_dump_examples
24
- end
14
+ output << %{<?xml version="1.0" encoding="UTF-8"?>\n}
15
+ output << %{<testsuite}
16
+ output << %{ name="rspec#{escape(ENV["TEST_ENV_NUMBER"].to_s)}"}
17
+ output << %{ tests="#{example_count}"}
18
+ output << %{ failures="#{failure_count}"}
19
+ output << %{ errors="0"}
20
+ output << %{ time="#{escape("%.6f" % duration)}"}
21
+ output << %{ timestamp="#{escape(started.iso8601)}"}
22
+ output << %{>\n}
23
+ output << %{<properties>\n}
24
+ output << %{<property}
25
+ output << %{ name="seed"}
26
+ output << %{ value="#{escape(RSpec.configuration.seed.to_s)}"}
27
+ output << %{/>\n}
28
+ output << %{</properties>\n}
29
+ xml_dump_examples
30
+ output << %{</testsuite>\n}
25
31
  end
26
32
 
27
33
  def xml_dump_examples
@@ -36,30 +42,85 @@ private
36
42
 
37
43
  def xml_dump_pending(example)
38
44
  xml_dump_example(example) do
39
- xml.skipped
45
+ output << %{<skipped/>}
40
46
  end
41
47
  end
42
48
 
43
49
  def xml_dump_failed(example)
44
50
  exception = exception_for(example)
45
- backtrace = formatted_backtrace_for(example)
46
51
 
47
52
  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
53
+ output << %{<failure}
54
+ output << %{ message="#{escape(exception.to_s)}"}
55
+ output << %{ type="#{escape(exception.class.name)}"}
56
+ output << %{>}
57
+ output << escape(failure_for(example))
58
+ output << %{</failure>}
51
59
  end
52
60
  end
53
61
 
54
- def xml_dump_example(example, &block)
55
- xml.testcase classname: classname_for(example), name: description_for(example), file: example_group_file_path_for(example), time: "%.6f" % duration_for(example), &block
62
+ def xml_dump_example(example)
63
+ output << %{<testcase}
64
+ output << %{ classname="#{escape(classname_for(example))}"}
65
+ output << %{ name="#{escape(description_for(example))}"}
66
+ output << %{ file="#{escape(example_group_file_path_for(example))}"}
67
+ output << %{ time="#{escape("%.6f" % duration_for(example))}"}
68
+ output << %{>}
69
+ yield if block_given?
70
+ output << %{</testcase>\n}
71
+ end
72
+
73
+ # Based on valid characters allowed in XML unescaped, with restricted and
74
+ # discouraged characters removed
75
+ #
76
+ # See https://www.w3.org/TR/xml/#dt-chardata
77
+ ESCAPE_REGEXP = Regexp.new(
78
+ "[^" <<
79
+ "\u{9}" << # => \t
80
+ "\u{a}" << # =>\n
81
+ "\u{d}" << # => \r
82
+ "\u{20}-\u{21}" <<
83
+ # "\u{22}" << # => "
84
+ "\u{23}-\u{25}" <<
85
+ # "\u{26}" << # => &
86
+ # "\u{27}" << # => '
87
+ "\u{28}-\u{3b}" <<
88
+ # "\u{3c}" << # => <
89
+ "\u{3d}" <<
90
+ # "\u{3e}" << # => >
91
+ "\u{3f}-\u{7e}" <<
92
+ # "\u{7f}-\u{84}" << # discouraged control characters
93
+ "\u{85}" <<
94
+ # "\u{86}-\u{9f}" << # discouraged control characters
95
+ "\u{a0}-\u{d7ff}" <<
96
+ "\u{e000}-\u{ffcf}" <<
97
+ # "\u{ffd0}-\u{fdef}" <<
98
+ "\u{fdf0}-\u{fffd}" <<
99
+ # things get murky from here, just escape anything with a higher codepoint
100
+ # "\u{10000}-\u{10ffff}" <<
101
+ "]"
102
+ )
103
+
104
+ # Translate well-known entities, or use generic unicode hex entity
105
+ ESCAPE_ENTITY = Hash.new { |_, c| "&##{c.ord.to_s(16)};".freeze }.update(
106
+ ?" => "&quot;".freeze,
107
+ ?& => "&amp;".freeze,
108
+ ?' => "&apos;".freeze,
109
+ ?< => "&lt;".freeze,
110
+ ?> => "&gt;".freeze,
111
+ ).freeze
112
+
113
+ def escape(text)
114
+ # Make sure it's utf-8 (this will throw errors for bad output, but that
115
+ # seems okay) and replace invalid xml characters with entities
116
+ text.to_s.encode(Encoding::UTF_8).gsub(ESCAPE_REGEXP, ESCAPE_ENTITY)
56
117
  end
57
118
  end
58
119
 
59
120
  RspecJunitFormatter = RSpecJUnitFormatter
60
121
 
61
- if RSpec::Core::Version::STRING.start_with? "3."
62
- require "rspec_junit_formatter/rspec3"
63
- else RSpec::Core::Version::STRING.start_with? "2."
122
+ if RSpec::Core::Version::STRING.start_with? "2."
64
123
  require "rspec_junit_formatter/rspec2"
124
+ else
125
+ require "rspec_junit_formatter/rspec3"
65
126
  end
@@ -13,12 +13,6 @@ class RSpecJUnitFormatter < RSpec::Core::Formatters::BaseFormatter
13
13
 
14
14
  private
15
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
16
  def result_of(example)
23
17
  example.execution_result[:status]
24
18
  end
@@ -48,7 +42,10 @@ private
48
42
  example.execution_result[:exception]
49
43
  end
50
44
 
51
- def formatted_backtrace_for(example)
52
- format_backtrace exception_for(example).backtrace, example
45
+ def failure_for(example)
46
+ exception = exception_for(example)
47
+ backtrace = format_backtrace(exception.backtrace, example)
48
+
49
+ "#{exception.message}\n#{backtrace.join("\n")}"
53
50
  end
54
51
  end
@@ -60,11 +60,11 @@ private
60
60
  notification.example.full_description
61
61
  end
62
62
 
63
- def exception_for(notification)
64
- notification.example.execution_result.exception
63
+ def failure_for(notification)
64
+ notification.message_lines.join("\n") << "\n" << notification.formatted_backtrace.join("\n")
65
65
  end
66
66
 
67
- def formatted_backtrace_for(notification)
68
- notification.formatted_backtrace
67
+ def exception_for(notification)
68
+ notification.example.execution_result.exception
69
69
  end
70
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_junit_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Cochran
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDKDCCAhCgAwIBAgIBAzANBgkqhkiG9w0BAQUFADA6MQ0wCwYDVQQDDARzajI2
13
+ MIIDKDCCAhCgAwIBAgIBBDANBgkqhkiG9w0BAQUFADA6MQ0wCwYDVQQDDARzajI2
14
14
  MRQwEgYKCZImiZPyLGQBGRYEc2oyNjETMBEGCgmSJomT8ixkARkWA2NvbTAeFw0x
15
- NTAzMTcyMjUwMjZaFw0xNjAzMTYyMjUwMjZaMDoxDTALBgNVBAMMBHNqMjYxFDAS
15
+ NjA3MjYxMTIxMjZaFw0xNzA3MjYxMTIxMjZaMDoxDTALBgNVBAMMBHNqMjYxFDAS
16
16
  BgoJkiaJk/IsZAEZFgRzajI2MRMwEQYKCZImiZPyLGQBGRYDY29tMIIBIjANBgkq
17
17
  hkiG9w0BAQEFAAOCAQ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JLPfq47UEuV1p5gy/f++aTxknsAYE/z/bfmO
29
+ EkIxoeESVQ0Kqhp754GWYv3Sfmtyk8UbGo5XCZHzvC6h2G7mplPzh6o+Edw=
30
30
  -----END CERTIFICATE-----
31
- date: 2015-06-03 00:00:00.000000000 Z
31
+ date: 2017-06-08 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec-core
@@ -56,20 +56,6 @@ dependencies:
56
56
  - - "!="
57
57
  - !ruby/object:Gem::Version
58
58
  version: 2.12.0
59
- - !ruby/object:Gem::Dependency
60
- name: builder
61
- requirement: !ruby/object:Gem::Requirement
62
- requirements:
63
- - - "<"
64
- - !ruby/object:Gem::Version
65
- version: '4'
66
- type: :runtime
67
- prerelease: false
68
- version_requirements: !ruby/object:Gem::Requirement
69
- requirements:
70
- - - "<"
71
- - !ruby/object:Gem::Version
72
- version: '4'
73
59
  - !ruby/object:Gem::Dependency
74
60
  name: nokogiri
75
61
  requirement: !ruby/object:Gem::Requirement
@@ -84,7 +70,7 @@ dependencies:
84
70
  - - "~>"
85
71
  - !ruby/object:Gem::Version
86
72
  version: '1.6'
87
- description: RSpec results that Hudson can read.
73
+ description: RSpec results that your continuous integration service can read.
88
74
  email: sj26@sj26.com
89
75
  executables: []
90
76
  extensions: []
@@ -107,15 +93,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
93
  requirements:
108
94
  - - ">="
109
95
  - !ruby/object:Gem::Version
110
- version: '0'
96
+ version: 2.0.0
111
97
  required_rubygems_version: !ruby/object:Gem::Requirement
112
98
  requirements:
113
99
  - - ">="
114
100
  - !ruby/object:Gem::Version
115
- version: 1.3.6
101
+ version: 2.0.0
116
102
  requirements: []
117
103
  rubyforge_project:
118
- rubygems_version: 2.4.5
104
+ rubygems_version: 2.6.11
119
105
  signing_key:
120
106
  specification_version: 4
121
107
  summary: RSpec JUnit XML formatter
metadata.gz.sig CHANGED
Binary file