rspec-junit 0.1.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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YmM4MWI2YmEyODE4N2ViODBkOGQ1OGU2NzE0ZWRlZWQ4ODVlZTUzOQ==
5
+ data.tar.gz: !binary |-
6
+ ZjEyZjgxMzYxMzc2MTczMWRhNjZhOWNkZGEyYmFmOWIzYTc0NTQ1OA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MjI3ZmVhNWVhNjNhMTkxNDMyM2E2MmQzM2M2NTMyNTk1ZGQxMjFhZGU0NGEy
10
+ NGI0YzkwNzA0MTVjMDMwMTE4NTFmZGYwOGYwM2QzNWNhZTk3ZGRjMmFkZGFj
11
+ NTA5YWRkNjQyY2I1NWUzZDFjZjQ1OWE3NDMwZjhkOTJmNjBmZTU=
12
+ data.tar.gz: !binary |-
13
+ M2EzZDRkOGJmMDE2ZmY0YzIwODFmNTQ0MTUyOTIxMDdjMjllZGFlMjk3NmNm
14
+ NjUwNWNjNTQyMDg2MjRlNzlkYTYyZGNhZmZkNTdkOGZjMzllOTE1Y2RkMjY2
15
+ OTMwZWNkNDQ5ZjM4NmQ5MWMzNTZlYzRhZDFjZjUwYWMzMjU2OTE=
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --require spec_helper
2
+ --format progress
3
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - 2.2.3
7
+ - 2.3.0
8
+ before_install: gem install bundler -v 1.13.6
9
+ cache: bundler
10
+ deploy:
11
+ provider: rubygems
12
+ gem:
13
+ master: rspec-junit
14
+ on:
15
+ repo: metova/rspec-junit
16
+ branch: master
17
+ api_key:
18
+ secure: ni/sim1H2G1uBq6d0bcCgWIRobJ2mPpOYWAmXZDfOUgTzIiW6xWvw+rVAt8bYaO4mVMEpX7FobEYB+yWK6lAHkmaxY7a4IMae3bc3qA/wPQzvd5TObutfPQCNonZ9rrb7cH9sgfqTcXRgpZNbJ5AsUk6aa+71WYHJCZ+8m9rdUJ3wOXgMHtIKmk0m56cbFBz75KWDPxr+aHO6yF43lkoi6F2kctzfgKAsDqwmLZWjBCtC8amvpO7puzLI6sgfcmz6Lf8WDEbnGE7cINEN4Ttati3JJViVjQFTz+dhEBneFySUq/8sYtxxgYiXfQCq2/1uMXNg7n9e409kEoMH+w4etyFD0lSw9qtaqWbTp3BBwYeZK2ps3NKVyebGBFZzdSLpuE1lBDUoX18+g/iyhsGyaZlabmWhknqsnphp2wOGw6PpyrLFDGv7uFPnoWSveFBi4MjtnN+ag7XCH1lUD6cAtxbgz6rEAPYF9RRsPLjBsfgu6fsLV5kvHII42dDd1IBNZd+OUXtXYsRJY2oNPil8jwWDMkl39+Vyni2IOsiRpv2voh2JczF+UgAztv6A3AvZOBycCRzAdlApS13Ij/biqdDjse8w4QlsCk6N1XhUYV1U4TwmvyCfBshJWVnvbejUUcDrnbDc8avV+JPLnW0f9bg8XZ014yv9EJbKTjdkpw=
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-junit.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Logan Serman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ ## RSpec::JUnit
2
+
3
+ This gem provides a custom JUnit formatter for RSpec >= 3.
4
+
5
+ ### Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rspec-junit'
11
+ ```
12
+
13
+ And then bundle.
14
+
15
+ ### Usage
16
+
17
+ RSpec uses the `-f` flag to specify a formatter and the `-o` flag to specify an output:
18
+
19
+ ```
20
+ bin/rspec -f RSpec::JUnit -o results/rspec-junit.xml
21
+ ```
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rspec/junit"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/rspec ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rspec' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,36 @@
1
+ require 'rspec/core/formatters'
2
+ require 'rspec/junit/version'
3
+ require 'rspec/junit/example_collection'
4
+ require 'rspec/junit/example'
5
+ require 'rspec/junit/failed_example'
6
+ require 'rspec/junit/passed_example'
7
+ require 'rspec/junit/pending_example'
8
+ require 'rspec/junit/renderer'
9
+
10
+ class RSpec::JUnit
11
+ RSpec::Core::Formatters.register self, :example_passed, :example_failed, :example_pending, :dump_summary
12
+
13
+ attr_reader :output, :examples
14
+
15
+ def initialize(output)
16
+ @output = output
17
+ @examples = RSpec::JUnit::ExampleCollection.new
18
+ end
19
+
20
+ def example_passed(notification)
21
+ @examples << RSpec::JUnit::PassedExample.new(notification)
22
+ end
23
+
24
+ def example_failed(notification)
25
+ @examples << RSpec::JUnit::FailedExample.new(notification)
26
+ end
27
+
28
+ def example_pending(notification)
29
+ @examples << RSpec::JUnit::PendingExample.new(notification)
30
+ end
31
+
32
+ def dump_summary(summary)
33
+ renderer = RSpec::JUnit::Renderer.new @examples, summary.duration
34
+ @output.puts renderer.render
35
+ end
36
+ end
@@ -0,0 +1,35 @@
1
+ module RSpec
2
+ class JUnit
3
+ class Example
4
+ attr_reader :notification
5
+
6
+ def initialize(notification)
7
+ @notification = notification
8
+ end
9
+
10
+ def passed?
11
+ false
12
+ end
13
+
14
+ def pending?
15
+ false
16
+ end
17
+
18
+ def failed?
19
+ false
20
+ end
21
+
22
+ def name
23
+ @notification.metadata[:full_description]
24
+ end
25
+
26
+ def testsuite
27
+ @notification.metadata[:example_group][:description]
28
+ end
29
+
30
+ def run_time
31
+ @notification.metadata[:execution_result].run_time
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,39 @@
1
+ module RSpec
2
+ class JUnit
3
+ class ExampleCollection
4
+ include ::Enumerable
5
+
6
+ attr_reader :examples
7
+
8
+ def initialize(examples = [])
9
+ @examples = examples
10
+ end
11
+
12
+ def <<(example)
13
+ @examples << example
14
+ end
15
+
16
+ def each(&block)
17
+ @examples.each(&block)
18
+ end
19
+
20
+ def each_testsuite
21
+ group_by(&:testsuite).each do |testsuite, examples|
22
+ yield testsuite, self.class.new(examples)
23
+ end
24
+ end
25
+
26
+ def passed
27
+ select(&:passed?)
28
+ end
29
+
30
+ def failed
31
+ select(&:failed?)
32
+ end
33
+
34
+ def pending
35
+ select(&:pending?)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,31 @@
1
+ require 'rspec/core/backtrace_formatter'
2
+
3
+ module RSpec
4
+ class JUnit
5
+ class FailedExample < Example
6
+ def failed?
7
+ true
8
+ end
9
+
10
+ def error_message
11
+ "failed #{name}"
12
+ end
13
+
14
+ def exception
15
+ @notification.exception
16
+ end
17
+
18
+ def exception_message
19
+ exception.message || ''
20
+ end
21
+
22
+ def backtrace
23
+ RSpec::Core::BacktraceFormatter.new.format_backtrace(exception.backtrace || [])
24
+ end
25
+
26
+ def details
27
+ [exception_message, backtrace].join "\n"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,9 @@
1
+ module RSpec
2
+ class JUnit
3
+ class PassedExample < Example
4
+ def passed?
5
+ true
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module RSpec
2
+ class JUnit
3
+ class PendingExample < Example
4
+ def pending?
5
+ true
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,78 @@
1
+ require 'builder'
2
+
3
+ module RSpec
4
+ class JUnit
5
+ class Renderer
6
+ attr_reader :examples, :duration, :builder
7
+
8
+ def initialize(examples, duration = 0)
9
+ @examples = examples
10
+ @duration = duration
11
+ @builder = Builder::XmlMarkup.new indent: 2
12
+ end
13
+
14
+ def render
15
+ builder.instruct! :xml, version: '1.0', encoding: 'UTF-8'
16
+ render_testsuites
17
+ builder.target!
18
+ end
19
+
20
+ def render_testsuites
21
+ builder.testsuites(testsuites_attributes) do
22
+ @examples.each_testsuite do |testsuite, examples|
23
+ render_testsuite testsuite, examples
24
+ end
25
+ end
26
+ end
27
+
28
+ def render_testsuite(testsuite, examples)
29
+ builder.testsuite(testsuite_attributes(testsuite, examples)) do
30
+ examples.each do |example|
31
+ render_testcase example
32
+ end
33
+ end
34
+ end
35
+
36
+ def render_testcase(example)
37
+ builder.testcase(testcase_attributes(example)) do
38
+ if example.failed?
39
+ builder.failure(message: example.error_message, type: :failed) do
40
+ builder.cdata! example.details
41
+ end
42
+ elsif example.pending?
43
+ builder.skipped
44
+ end
45
+ end
46
+ end
47
+
48
+ private
49
+ def testsuites_attributes
50
+ {
51
+ errors: 0,
52
+ tests: examples.count,
53
+ failures: examples.failed.count,
54
+ skipped: examples.pending.count,
55
+ time: duration,
56
+ timestamp: Time.now.iso8601
57
+ }
58
+ end
59
+
60
+ def testsuite_attributes(name, examples)
61
+ {
62
+ name: name,
63
+ errors: 0,
64
+ tests: examples.count,
65
+ failures: examples.failed.count,
66
+ skipped: examples.pending.count
67
+ }
68
+ end
69
+
70
+ def testcase_attributes(example)
71
+ {
72
+ name: example.name,
73
+ time: example.run_time
74
+ }
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,5 @@
1
+ module RSpec
2
+ class JUnit
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspec/junit/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'rspec-junit'
8
+ spec.version = RSpec::JUnit::VERSION
9
+ spec.authors = ['Logan Serman']
10
+ spec.email = ['logan.serman@metova.com']
11
+
12
+ spec.summary = 'Provides a JUnit formatter for RSpec'
13
+ spec.description = spec.summary
14
+ spec.homepage = 'https://github.com/metova/rspec-junit'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_dependency 'builder'
26
+ spec.add_dependency 'rspec', '>= 3'
27
+
28
+ spec.add_development_dependency 'bundler', '~> 1.13'
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'timecop'
31
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-junit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Logan Serman
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-10-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: builder
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: timecop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Provides a JUnit formatter for RSpec
84
+ email:
85
+ - logan.serman@metova.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - .travis.yml
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/rspec
99
+ - bin/setup
100
+ - lib/rspec/junit.rb
101
+ - lib/rspec/junit/example.rb
102
+ - lib/rspec/junit/example_collection.rb
103
+ - lib/rspec/junit/failed_example.rb
104
+ - lib/rspec/junit/passed_example.rb
105
+ - lib/rspec/junit/pending_example.rb
106
+ - lib/rspec/junit/renderer.rb
107
+ - lib/rspec/junit/version.rb
108
+ - rspec-junit.gemspec
109
+ homepage: https://github.com/metova/rspec-junit
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.4.5
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Provides a JUnit formatter for RSpec
133
+ test_files: []