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_pending(summary) ⇒ Object
- #dump_summary(summary) ⇒ Object
- #example_failed(failed) ⇒ 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 17 18 |
# 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 = [] @progress = RSpec::Core::Formatters::ProgressFormatter.new(STDOUT) @summary = RSpec::Core::Formatters::BaseTextFormatter.new(STDOUT) @failures = 0 end |
Instance Method Details
#dump_pending(summary) ⇒ Object
99 100 101 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 99 def dump_pending(summary) @summary.dump_pending(summary) if @failures == 0 end |
#dump_summary(summary) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 59 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! puts @summary.dump_summary(summary) end |
#example_failed(failed) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 42 def example_failed(failed) @test_results << failed @progress.example_failed(failed) puts failures = @failures puts failed.fully_formatted(failures) @failures += 1 end |
#example_group_started(notification) ⇒ Object
24 25 26 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 24 def example_group_started(notification) end |
#example_passed(passed) ⇒ Object
36 37 38 39 40 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 36 def example_passed(passed) @test_results << passed @progress.example_passed(passed) end |
#example_pending(pending) ⇒ Object
53 54 55 56 57 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 53 def example_pending(pending) @test_results << pending @progress.example_pending(pending) end |
#example_started(notification) ⇒ Object
32 33 34 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 32 def example_started(notification) end |
#start(notification) ⇒ Object
20 21 22 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 20 def start(notification) end |
#start_dump(notification) ⇒ Object
28 29 30 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 28 def start_dump(notification) end |