rspec_junit_formatter 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require "time"
|
2
|
+
|
3
|
+
require "builder"
|
4
|
+
require "rspec"
|
5
|
+
|
6
|
+
require "rspec/core/formatters/base_formatter"
|
2
7
|
|
3
8
|
# Dumps rspec results as a JUnit XML file.
|
4
9
|
# Based on XML schema: http://windyroad.org/dl/Open%20Source/JUnit.xsd
|
@@ -6,46 +11,57 @@ class RSpec::Core::Formatters::JUnitFormatter < RSpec::Core::Formatters::BaseFor
|
|
6
11
|
def xml
|
7
12
|
@xml ||= Builder::XmlMarkup.new :target => output, :indent => 2
|
8
13
|
end
|
9
|
-
|
14
|
+
|
10
15
|
def start example_count
|
11
16
|
@start = Time.now
|
12
17
|
super
|
13
18
|
end
|
14
|
-
|
19
|
+
|
15
20
|
def dump_summary duration, example_count, failure_count, pending_count
|
16
21
|
super
|
17
|
-
|
22
|
+
|
18
23
|
xml.instruct!
|
19
|
-
xml.testsuite :tests => example_count, :failures => failure_count, :errors => 0, :time =>
|
24
|
+
xml.testsuite :tests => example_count, :failures => failure_count, :errors => 0, :time => "%.6f" % duration, :timestamp => @start.iso8601 do
|
20
25
|
xml.properties
|
21
26
|
examples.each do |example|
|
22
27
|
send :"dump_summary_example_#{example.execution_result[:status]}", example
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
26
|
-
|
31
|
+
|
27
32
|
def xml_example example, &block
|
28
|
-
xml.testcase :classname => example.file_path, :name => example.full_description, :time =>
|
33
|
+
xml.testcase :classname => example.file_path, :name => example.full_description, :time => "%.6f" % example.execution_result[:run_time], &block
|
29
34
|
end
|
30
|
-
|
35
|
+
|
31
36
|
def dump_summary_example_passed example
|
32
37
|
xml_example example
|
33
38
|
end
|
34
|
-
|
39
|
+
|
35
40
|
def dump_summary_example_pending example
|
36
41
|
xml_example example do
|
37
42
|
xml.skipped
|
38
43
|
end
|
39
44
|
end
|
40
|
-
|
45
|
+
|
41
46
|
def dump_summary_example_failed example
|
42
47
|
exception = example.execution_result[:exception]
|
43
48
|
backtrace = format_backtrace exception.backtrace, example
|
44
|
-
|
49
|
+
|
45
50
|
xml_example example do
|
46
51
|
xml.failure :message => exception.to_s, :type => exception.class.name do
|
47
52
|
xml.cdata! "#{exception.message}\n#{backtrace.join "\n"}"
|
48
53
|
end
|
49
54
|
end
|
50
55
|
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
# Rspec 2.12 changes the signature of format_backtrace, so we
|
60
|
+
# presume the new version is in play unless we can check that
|
61
|
+
# the loaded gem version is below 2.12
|
62
|
+
if not defined? Gem or Gem.loaded_specs["rspec"].version >= Gem::Version.new("2.12")
|
63
|
+
def format_backtrace backtrace, example
|
64
|
+
super backtrace, example.metadata
|
65
|
+
end
|
66
|
+
end
|
51
67
|
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require 'rspec'
|
3
|
-
|
4
|
-
require 'rspec/core/formatters/base_formatter'
|
5
|
-
require 'rspec/core/formatters/j_unit_formatter'
|
1
|
+
require "rspec/core/formatters/j_unit_formatter"
|
6
2
|
|
7
3
|
# Make it easier to use
|
8
4
|
RspecJunitFormatter = RSpecJUnitFormatter = RSpec::Core::Formatters::JUnitFormatter
|
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|