Sha256: 444e11f52e09a107505c44ed4aa2773b1408a3e1a3a26fef108b6c77e27fa40a

Contents?: true

Size: 1.35 KB

Versions: 33

Compression:

Stored size: 1.35 KB

Contents

require 'rspec/core/formatters/base_formatter'
require 'json'

module RSpec
  module Core
    module Formatters
      class GorgonRspecFormatter < BaseFormatter
        attr_reader :output

        def initialize(output)
          super
          @failures = []
        end

        def message(message)
          @failures += message unless @failures.empty?
        end

        def stop
          super
          failures = examples.select { |e| e.execution_result[:status] == "failed" }

          @failures += failures.map do |failure|
            {
              :test_name => "#{failure.full_description}: " \
              "line #{failure.metadata[:line_number]}",
              :description => failure.description,
              :full_description => failure.full_description,
              :status => failure.execution_result[:status],
              :file_path => failure.metadata[:file_path],
              :line_number  => failure.metadata[:line_number],
            }.tap do |hash|
              if e=failure.exception
                hash[:class] = e.class.name
                hash[:message] = e.message
                hash[:location] = e.backtrace
              end
            end
          end
        end

        def close
          output.write @failures.to_json
          output.close if IO === output && output != $stdout
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
gorgon-0.5.0.rc1 lib/gorgon/gorgon_rspec_formatter.rb
gorgon-0.4.5 lib/gorgon/gorgon_rspec_formatter.rb
gorgon-0.4.5.rc1 lib/gorgon/gorgon_rspec_formatter.rb
gorgon-0.4.4 lib/gorgon/gorgon_rspec_formatter.rb
gorgon-0.4.3 lib/gorgon/gorgon_rspec_formatter.rb
gorgon-0.4.2 lib/gorgon/gorgon_rspec_formatter.rb
gorgon-0.4.1 lib/gorgon/gorgon_rspec_formatter.rb
gorgon-0.4.1.rc1 lib/gorgon/gorgon_rspec_formatter.rb
gorgon-0.4.0 lib/gorgon/gorgon_rspec_formatter.rb
gorgon-0.4.0.rc2 lib/gorgon/gorgon_rspec_formatter.rb
gorgon-0.4.0.rc1 lib/gorgon/gorgon_rspec_formatter.rb
gorgon-0.3.2 lib/gorgon/gorgon_rspec_formatter.rb
gorgon-0.3.1 lib/gorgon/gorgon_rspec_formatter.rb