rspec_junit_formatter 0.4.0.pre2 → 0.4.0

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
- SHA1:
3
- metadata.gz: 7e45b452b3b1ddc9a5fe134c0f440b5c75f61ede
4
- data.tar.gz: cb0b99afd6014613c513c98e52cdf7b7244e07a6
2
+ SHA256:
3
+ metadata.gz: 615b543d4cbd284941621231bb5fbc4132a1991a9032d9f35e2d63dd1461a5e3
4
+ data.tar.gz: 5a62fe31f2292c2c80c152e3ecbdafaf5d960838d1e729574bf6479bc6fd7599
5
5
  SHA512:
6
- metadata.gz: f49ef97111a63bb72f5b4b55eba04f1afa1e17e6f1a57a1d0f492b3030db8d810f3ba1dded5bfbae9b27f77284282148c51c763c974352f9abcb42bbde82284f
7
- data.tar.gz: 5a3421440dec87320bd86e230a31e18fdd395ab41d6c105296b3cef80101f49c3bc2696e77762184a0d030e8634e2182922b1889449c55b9b3a6ca78c6c17649
6
+ metadata.gz: 79c1155ccd8b77d1dc9176bd6eb033cb4bc3a4d2b2452421180dae502f96ab98c36010db89d5bcee9f943fd5959b7241b12a12f14f60548de8034efe04a2af23
7
+ data.tar.gz: 249d53fef2a5a8e5f5abc0d38f803f9a628d075e53f5448e580265714b9d38c87f49cef98c3e91a0f047311f8ece77629a837229c6ecd4abe1765f93f1da3ce5
Binary file
data.tar.gz.sig CHANGED
Binary file
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Samuel Cochran
1
+ Copyright (c) 2011-2018 Samuel Cochran
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -3,9 +3,12 @@
3
3
  [![Build results](http://img.shields.io/travis/sj26/rspec_junit_formatter/master.svg)](https://travis-ci.org/sj26/rspec_junit_formatter)
4
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 services, too.
6
+ [RSpec][rspec] 2 & 3 results that your CI can read. [Jenkins][jenkins-junit], [Buildkite][buildkite-junit], [CircleCI][circleci-junit], and probably more, too.
7
7
 
8
- Inspired by the work of [Diego Souza][dgvncsz0f] on [RSpec Formatters][dgvncsz0f/rspec_formatters] after frustration with [CI Reporter][ci_reporter].
8
+ [rspec]: http://rspec.info/
9
+ [jenkins-junit]: https://jenkins.io/doc/pipeline/steps/junit/
10
+ [buildkite-junit]: https://github.com/buildkite/rspec-junit-example
11
+ [circleci-junit]: https://circleci.com/docs/2.0/collect-test-data/
9
12
 
10
13
  ## Usage
11
14
 
@@ -29,6 +32,8 @@ You can use it in combination with other [formatters][rspec-formatters], too:
29
32
  rspec --format progress --format RspecJunitFormatter --out rspec.xml
30
33
  ```
31
34
 
35
+ [rspec-formatters]: https://relishapp.com/rspec/rspec-core/v/3-6/docs/formatters
36
+
32
37
  ### Using in your project with Bundler
33
38
 
34
39
  Add it to your Gemfile if you're using [Bundler][bundler]. Put it in the same groups as rspec.
@@ -46,6 +51,8 @@ Put the same arguments as the commands above in [your `.rspec`][rspec-file]:
46
51
  --format RspecJunitFormatter
47
52
  --out rspec.xml
48
53
  ```
54
+ [bundler]: https://bundler.io
55
+ [rspec-file]: https://relishapp.com/rspec/rspec-core/v/3-6/docs/configuration/read-command-line-configuration-options-from-files
49
56
 
50
57
  ### Parallel tests
51
58
 
@@ -58,17 +65,45 @@ For use with `parallel_tests`, add `$TEST_ENV_NUMBER` in the output file option
58
65
 
59
66
  The formatter includes `$TEST_ENV_NUMBER` in the test suite name within the XML, too.
60
67
 
68
+ ### Capturing output
69
+
70
+ If you like, you can capture the standard output and error streams of each test into the `:stdout` and `:stderr` example metadata which will be added to the junit report, e.g.:
71
+
72
+ ```ruby
73
+ # spec_helper.rb
74
+
75
+ RSpec.configure do |config|
76
+ # register around filter that captures stdout and stderr
77
+ config.around(:each) do |example|
78
+ $stdout = StringIO.new
79
+ $stderr = StringIO.new
80
+
81
+ example.run
82
+
83
+ example.metadata[:stdout] = $stdout.string
84
+ example.metadata[:stderr] = $stderr.string
85
+
86
+ $stdout = STDOUT
87
+ $stderr = STDERR
88
+ end
89
+ end
90
+ ```
91
+
61
92
  ## Caveats
62
93
 
63
94
  * XML can only represent a [limited subset of characters][xml-charsets] which excludes null bytes and most control characters. This gem will use character entities where possible and fall back to replacing invalid characters with Ruby-like escape codes otherwise. For example, the null byte becomes `\0`.
64
95
 
96
+ [xml-charsets]: https://www.w3.org/TR/xml/#charsets
97
+
65
98
  ## Roadmap
66
99
 
67
100
  * 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.
68
101
 
69
102
  ## Development
70
103
 
71
- Run the specs with `bundle exec rake spec`. Run the specs against a matrix of rspec versions using `bundle exec rake spec:all`.
104
+ Run the specs with `bundle exec rake`, which uses [Appraisal][appraisal] to run the specs against all supported versions of rspec.
105
+
106
+ [appraisal]: https://github.com/thoughtbot/appraisal
72
107
 
73
108
  ## Releasing
74
109
 
@@ -76,16 +111,12 @@ Bump the gem version in the gemspec, and commit. Then `bundle exec rake build` t
76
111
 
77
112
  ## License
78
113
 
79
- The MIT License, see [LICENSE][license].
114
+ The MIT License, see [LICENSE](./LICENSE).
115
+
116
+ ## Thanks
117
+
118
+ Inspired by the work of [Diego Souza][dgvncsz0f] on [RSpec Formatters][dgvncsz0f/rspec_formatters] after frustration with [CI Reporter][ci_reporter].
80
119
 
81
- [rspec]: http://rspec.info/
82
- [rspec-formatters]: https://relishapp.com/rspec/rspec-core/v/3-6/docs/formatters
83
- [rspec-file]: https://relishapp.com/rspec/rspec-core/v/3-6/docs/configuration/read-command-line-configuration-options-from-files
84
- [jenkins]: http://jenkins-ci.org/
85
120
  [dgvncsz0f]: https://github.com/dgvncsz0f
86
121
  [dgvncsz0f/rspec_formatters]: https://github.com/dgvncsz0f/rspec_formatters
87
122
  [ci_reporter]: https://github.com/nicksieger/ci_reporter
88
- [bundler]: http://gembundler.com/
89
- [fuubar]: http://jeffkreeftmeijer.com/2010/fuubar-the-instafailing-rspec-progress-bar-formatter/
90
- [license]: https://github.com/sj26/rspec-junit-formatter/blob/master/LICENSE
91
- [xml-charsets]: https://www.w3.org/TR/xml/#charsets
@@ -71,9 +71,24 @@ private
71
71
  output << %{ time="#{escape("%.6f" % duration_for(example))}"}
72
72
  output << %{>}
73
73
  yield if block_given?
74
+ xml_dump_output(example)
74
75
  output << %{</testcase>\n}
75
76
  end
76
77
 
78
+ def xml_dump_output(example)
79
+ if (stdout = stdout_for(example)) && !stdout.empty?
80
+ output << %{<system-out>}
81
+ output << escape(stdout)
82
+ output << %{</system-out>}
83
+ end
84
+
85
+ if (stderr = stderr_for(example)) && !stderr.empty?
86
+ output << %{<system-err>}
87
+ output << escape(stderr)
88
+ output << %{</system-err>}
89
+ end
90
+ end
91
+
77
92
  # Inversion of character range from https://www.w3.org/TR/xml/#charsets
78
93
  ILLEGAL_REGEXP = Regexp.new(
79
94
  "[^" <<
@@ -69,4 +69,12 @@ private
69
69
  def group_and_parent_groups(example)
70
70
  example.example_group.parent_groups + [example.example_group]
71
71
  end
72
+
73
+ def stdout_for(example)
74
+ example.metadata[:stdout]
75
+ end
76
+
77
+ def stderr_for(example)
78
+ example.metadata[:stderr]
79
+ end
72
80
  end
@@ -122,6 +122,14 @@ private
122
122
  yield
123
123
  end
124
124
  end
125
+
126
+ def stdout_for(example_notification)
127
+ example_notification.example.metadata[:stdout]
128
+ end
129
+
130
+ def stderr_for(example_notification)
131
+ example_notification.example.metadata[:stderr]
132
+ end
125
133
  end
126
134
 
127
135
  # rspec-core 3.0.x forgot to mark this as a module function which causes:
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.4.0.pre2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Cochran
@@ -28,7 +28,7 @@ cert_chain:
28
28
  P4lSfmXxsd1C71ckIp0cyXkPhyTtpyS/5hq9HhuUNzEHkSDe36/Rd1xYKV5JxMC2
29
29
  YAttWFUs06lor2q1wwncPaMtUtbWwW35+1IV6xhs2rFY6DD/I6ZkK3GnHdY=
30
30
  -----END CERTIFICATE-----
31
- date: 2017-12-17 00:00:00.000000000 Z
31
+ date: 2018-05-26 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec-core
@@ -60,58 +60,78 @@ dependencies:
60
60
  name: bundler
61
61
  requirement: !ruby/object:Gem::Requirement
62
62
  requirements:
63
- - - "~>"
63
+ - - ">="
64
64
  - !ruby/object:Gem::Version
65
- version: '1.16'
65
+ version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
- - - "~>"
70
+ - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: '1.16'
72
+ version: '0'
73
+ - !ruby/object:Gem::Dependency
74
+ name: appraisal
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
73
87
  - !ruby/object:Gem::Dependency
74
88
  name: nokogiri
75
89
  requirement: !ruby/object:Gem::Requirement
76
90
  requirements:
77
91
  - - "~>"
78
92
  - !ruby/object:Gem::Version
79
- version: '1.6'
93
+ version: '1.8'
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.8.2
80
97
  type: :development
81
98
  prerelease: false
82
99
  version_requirements: !ruby/object:Gem::Requirement
83
100
  requirements:
84
101
  - - "~>"
85
102
  - !ruby/object:Gem::Version
86
- version: '1.6'
103
+ version: '1.8'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 1.8.2
87
107
  - !ruby/object:Gem::Dependency
88
108
  name: rake
89
109
  requirement: !ruby/object:Gem::Requirement
90
110
  requirements:
91
- - - "~>"
111
+ - - ">="
92
112
  - !ruby/object:Gem::Version
93
- version: '10.0'
113
+ version: '0'
94
114
  type: :development
95
115
  prerelease: false
96
116
  version_requirements: !ruby/object:Gem::Requirement
97
117
  requirements:
98
- - - "~>"
118
+ - - ">="
99
119
  - !ruby/object:Gem::Version
100
- version: '10.0'
120
+ version: '0'
101
121
  - !ruby/object:Gem::Dependency
102
122
  name: coderay
103
123
  requirement: !ruby/object:Gem::Requirement
104
124
  requirements:
105
- - - "~>"
125
+ - - ">="
106
126
  - !ruby/object:Gem::Version
107
- version: '1.0'
127
+ version: '0'
108
128
  type: :development
109
129
  prerelease: false
110
130
  version_requirements: !ruby/object:Gem::Requirement
111
131
  requirements:
112
- - - "~>"
132
+ - - ">="
113
133
  - !ruby/object:Gem::Version
114
- version: '1.0'
134
+ version: '0'
115
135
  description: RSpec results that your continuous integration service can read.
116
136
  email: sj26@sj26.com
117
137
  executables: []
@@ -143,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
163
  version: 2.0.0
144
164
  requirements: []
145
165
  rubyforge_project:
146
- rubygems_version: 2.6.13
166
+ rubygems_version: 2.7.5
147
167
  signing_key:
148
168
  specification_version: 4
149
169
  summary: RSpec JUnit XML formatter
metadata.gz.sig CHANGED
Binary file