Class: RightDevelop::CI::Formatters::RSpecV2

Inherits:
RSpec::Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/right_develop/ci/formatters/rspec_v2.rb

Overview

JUnit XML output formatter for RSpec 2.x

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RSpecV2

Returns a new instance of RSpecV2.



4
5
6
7
# File 'lib/right_develop/ci/formatters/rspec_v2.rb', line 4

def initialize(*args)
  super(*args)
  @test_results = []
end

Instance Method Details

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



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/right_develop/ci/formatters/rspec_v2.rb', line 21

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 do |test|
      classname        = purify(classname_for(test))
      full_description = purify(test.full_description)
      time             = test.[: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.[: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(example) ⇒ Object



13
14
15
# File 'lib/right_develop/ci/formatters/rspec_v2.rb', line 13

def example_failed(example)
  @test_results << example
end

#example_passed(example) ⇒ Object



9
10
11
# File 'lib/right_develop/ci/formatters/rspec_v2.rb', line 9

def example_passed(example)
  @test_results << example
end

#example_pending(example) ⇒ Object



17
18
19
# File 'lib/right_develop/ci/formatters/rspec_v2.rb', line 17

def example_pending(example)
  @test_results << example
end