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.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 23 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
113 114 115 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 113 def dump_pending(summary) @summary.dump_pending(summary) if @failures == 0 end |
#dump_summary(summary) ⇒ Object
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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 73 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
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 56 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
38 39 40 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 38 def example_group_started(notification) end |
#example_passed(passed) ⇒ Object
50 51 52 53 54 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 50 def example_passed(passed) @test_results << passed @progress.example_passed(passed) end |
#example_pending(pending) ⇒ Object
67 68 69 70 71 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 67 def example_pending(pending) @test_results << pending @progress.example_pending(pending) end |
#example_started(notification) ⇒ Object
46 47 48 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 46 def example_started(notification) end |
#start(notification) ⇒ Object
34 35 36 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 34 def start(notification) end |
#start_dump(notification) ⇒ Object
42 43 44 |
# File 'lib/right_develop/ci/formatters/rspec_v3.rb', line 42 def start_dump(notification) end |