rspec_junit 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 438603445030cb63875f102322c94f391eedb590
4
- data.tar.gz: b53694363ec0b8a6702347fde9061ac8ba6ba9c6
3
+ metadata.gz: f729b0494c3aeecd11d3bf5a6df48052686c84ba
4
+ data.tar.gz: 264c0d89a7bf1f80679b00692e399d664cc6ccf1
5
5
  SHA512:
6
- metadata.gz: 9ab5823f87d44de4f921de756bfff8f09cdb32310dfbc602fb8c9a2b5ddecbb20902c553bc7e933b58bfa7747e8403b065fcce29dea7eaf9df3120d3e5352941
7
- data.tar.gz: d3396364f0670a7b9dc5b430a4eb958818a65beee968ff355e0f08fbac814f0e9e236efadecc77126c2b0d226a01de36c619df388ef46d9d74107e74fe853d22
6
+ metadata.gz: ad33e37b9f91f2cf934efb758e8f9cb7182464f2775816f5dc7b9cf580e2291920a0beea2f9918ac269a96b1760a6e820030816cb3b01d09146f2c4c091e51e8
7
+ data.tar.gz: 2ad58ed53cd96daf6afa73f873a3f7b2dff05e68d65b9e74e4fd0e44f9ae5ebc2ffbaee77f6602a52739a928fb1dedf7f9087cfa3197712383cdb55851c45956
data/README.md CHANGED
@@ -18,6 +18,15 @@ Usage:
18
18
 
19
19
  - `require 'rspec_junit'`
20
20
 
21
+
22
+ ```
23
+ $ cat .rspec
24
+ --require rspec_junit
25
+ --format documentation
26
+ --format JUnit
27
+ --out ./junit/junit_<%= Process.pid %>.xml
28
+ ```
29
+
21
30
  --
22
31
 
23
32
  ## Intro
@@ -1,11 +1,14 @@
1
- # An RSpec formatter for generating results in JUnit format
1
+ # RSpec formatter for generating results in JUnit format
2
+ # Inherit from BaseFormatter like the JSON rspec-core formatter.
2
3
  class JUnit < RSpec::Core::Formatters::BaseFormatter
3
- RSpec::Core::Formatters.register self, :example_passed, :example_failed, :example_pending, :dump_summary
4
+ RSpec::Core::Formatters.register self, :example_passed, :example_failed,
5
+ :example_pending, :dump_summary,
6
+ :close
4
7
 
5
8
  def initialize(output)
6
9
  super
7
10
  @test_suite_results = {}
8
- @builder = Builder::XmlMarkup.new :indent => 2
11
+ @builder = Builder::XmlMarkup.new indent: 2
9
12
  end
10
13
 
11
14
  def example_passed(example_notification)
@@ -25,6 +28,17 @@ class JUnit < RSpec::Core::Formatters::BaseFormatter
25
28
  @output.puts @builder.target!
26
29
  end
27
30
 
31
+ # close is required to output files correctly.
32
+ # Use with Process.pid to have unique names
33
+ # close code modified from: lib/rspec/core/formatters/base_text_formatter.rb
34
+ def close(_notification)
35
+ return unless IO === output
36
+ return if output.closed?
37
+
38
+ output.flush
39
+ output.close unless output == $stdout
40
+ end
41
+
28
42
  protected
29
43
 
30
44
  def add_to_test_suite_results(example_notification)
@@ -34,13 +48,14 @@ class JUnit < RSpec::Core::Formatters::BaseFormatter
34
48
  end
35
49
 
36
50
  def failure_details_for(example)
37
- exception = example.exception
38
- exception_backtrace = exception.backtrace
39
- formatted_backtrace = ''
40
- if exception_backtrace # may be nil
41
- formatted_backtrace = "\n#{RSpec::Core::BacktraceFormatter.new.format_backtrace exception_backtrace}"
51
+ exception = example.exception
52
+ return '' if exception.nil?
53
+ backtrace = ''
54
+ if exception.backtrace # may be nil
55
+ backtrace = RSpec::Core::BacktraceFormatter.new.format_backtrace exception.backtrace
56
+ backtrace = "\n#{backtrace.join("\n")}"
42
57
  end
43
- exception.nil? ? '' : "#{exception.message}#{formatted_backtrace}"
58
+ "\n#{exception.class.name}\n#{exception.message}#{backtrace}"
44
59
  end
45
60
 
46
61
  # utility methods
@@ -56,14 +71,14 @@ class JUnit < RSpec::Core::Formatters::BaseFormatter
56
71
  # methods to build the xml for test suites and individual tests
57
72
 
58
73
  def build_results(duration, example_count, failure_count, pending_count)
59
- @builder.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
74
+ @builder.instruct! :xml, version: '1.0', encoding: 'UTF-8'
60
75
  @builder.testsuites(
61
- :errors => 0,
62
- :failures => failure_count,
63
- :skipped => pending_count,
64
- :tests => example_count,
65
- :time => duration,
66
- :timestamp => Time.now.iso8601) do
76
+ errors: 0,
77
+ failures: failure_count,
78
+ skipped: pending_count,
79
+ tests: example_count,
80
+ time: duration,
81
+ timestamp: Time.now.iso8601) do
67
82
  build_all_suites
68
83
  end
69
84
  end
@@ -79,12 +94,12 @@ class JUnit < RSpec::Core::Formatters::BaseFormatter
79
94
  skipped_count = JUnit.count_in_suite_of_type(tests, :pending)
80
95
 
81
96
  @builder.testsuite(
82
- :location => tests.first.example_group.location,
83
- :name => suite_name,
84
- :tests => tests.size,
85
- :errors => 0,
86
- :failures => failure_count,
87
- :skipped => skipped_count) do
97
+ location: tests.first.example_group.location,
98
+ name: suite_name,
99
+ tests: tests.size,
100
+ errors: 0,
101
+ failures: failure_count,
102
+ skipped: skipped_count) do
88
103
  @builder.properties
89
104
  build_all_tests tests
90
105
  end
@@ -102,7 +117,7 @@ class JUnit < RSpec::Core::Formatters::BaseFormatter
102
117
  test_status = test.metadata[:execution_result].status
103
118
  location = test.location
104
119
 
105
- @builder.testcase(:name => test_name, :time => execution_time, :location => location) do
120
+ @builder.testcase(name: test_name, time: execution_time, location: location) do
106
121
  case test_status
107
122
  when :pending
108
123
  @builder.skipped
@@ -115,7 +130,7 @@ class JUnit < RSpec::Core::Formatters::BaseFormatter
115
130
  def build_failed_test(test)
116
131
  failure_message = "failed #{test.metadata[:full_description]}"
117
132
 
118
- @builder.failure(:message => failure_message, :type => 'failed') do
133
+ @builder.failure(message: failure_message, type: 'failed') do
119
134
  @builder.cdata!(failure_details_for(test))
120
135
  end
121
136
  end
@@ -1,4 +1,4 @@
1
1
  module RspecJunit
2
- VERSION = '3.0.3' unless defined? ::RspecJunit::VERSION
3
- DATE = '2015-10-14' unless defined? ::RspecJunit::DATE
2
+ VERSION = '3.0.4' unless defined? ::RspecJunit::VERSION
3
+ DATE = '2015-10-15' unless defined? ::RspecJunit::DATE
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_junit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Ritmeyer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-14 00:00:00.000000000 Z
12
+ date: 2015-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec