Class: RightDevelop::CI::Formatters::RSpecV3
- Inherits:
-
RSpec::Core::Formatters::BaseFormatter
- Object
- RSpec::Core::Formatters::BaseFormatter
- RightDevelop::CI::Formatters::RSpecV3
- Defined in:
- lib/right_develop/ci/formatters/rspec_v3.rb
Overview
JUnit XML output formatter for RSpec 3.x
Instance Method Summary collapse
- #dump_summary(summary) ⇒ Object
- #example_failed(failure) ⇒ Object
- #example_group_started(notification) ⇒ Object
- #example_passed(passed) ⇒ Object
- #example_pending(pending) ⇒ Object
- #example_started(notification) ⇒ Object
-
#initialize(output) ⇒ RSpecV3
constructor
A new instance of RSpecV3.
- #start(notification) ⇒ Object
- #start_dump(notification) ⇒ Object
Constructor Details
#initialize(output) ⇒ RSpecV3
Returns a new instance of RSpecV3.
9 10 11 12 13 14 15 16 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 9 def initialize(output) super(output) @failed_examples = [] @example_group_number = 0 @example_number = 0 @test_results = [] end |
Instance Method Details
#dump_summary(summary) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 46 def dump_summary(summary) builder = Builder::XmlMarkup.new :indent => 2 builder.instruct! :xml, :version => "1.0", :encoding => "UTF-8" builder.testsuite :errors => 0, :failures => summary.failure_count, :skipped => summary.pending_count, :tests => summary.example_count, :time => summary.duration, :timestamp => Time.now.iso8601 do builder.properties @test_results.each do |test| classname = purify(classname_for(test.example)) full_description = purify(test.example.full_description) time = test.example.[:execution_result][:run_time] # The full description always begins with the classname, but this is useless info when # generating the XML report. if full_description.start_with?(classname) full_description = full_description[classname.length..-1].strip end builder.testcase(:classname => classname.to_sym, :name => full_description, :time => time) do case test.example.[:execution_result][:status] when "failed" builder.failure :message => "failed #{full_description}", :type => "failed" do builder.cdata! purify(failure_details_for(test)) end when "pending" then builder.skipped end end end end output.puts builder.target! end |
#example_failed(failure) ⇒ Object
38 39 40 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 38 def example_failed(failure) @test_results << failure end |
#example_group_started(notification) ⇒ Object
22 23 24 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 22 def example_group_started(notification) end |
#example_passed(passed) ⇒ Object
34 35 36 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 34 def example_passed(passed) @test_results << passed end |
#example_pending(pending) ⇒ Object
42 43 44 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 42 def example_pending(pending) @test_results << pending end |
#example_started(notification) ⇒ Object
30 31 32 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 30 def example_started(notification) end |
#start(notification) ⇒ Object
18 19 20 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 18 def start(notification) end |
#start_dump(notification) ⇒ Object
26 27 28 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 26 def start_dump(notification) end |