Method: RightDevelop::CI::Formatters::RSpecV1#dump_summary

Defined in:
lib/right_develop/ci/formatters/rspec_v1.rb

#dump_summary(duration, example_count, failure_count, pending_count) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/right_develop/ci/formatters/rspec_v1.rb', line 41

def dump_summary(duration, example_count, failure_count, pending_count)
  builder = Builder::XmlMarkup.new :indent => 2
  builder.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
  builder.testsuite :errors => 0, :failures => failure_count, :skipped => pending_count, :tests => example_count, :time => duration, :timestamp => Time.now.iso8601 do
    builder.properties
    @test_results.each_pair do |test, result|
      classname        = purify(classname_for(test))
      full_description = purify(test.description)

      # 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 => @test_times[test]) do
        case result
        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