Sha256: 99ac8b2e5584112cfd57af681367cd0438a479f69f7aa6f119687d40c3e79c9d

Contents?: true

Size: 2 KB

Versions: 11

Compression:

Stored size: 2 KB

Contents

require 'teabag/formatters/base_formatter'
require 'yaml'

module Teabag
  module Formatters
    class TapYFormatter < BaseFormatter

      def runner(result)
        log "type"  => "suite",
            "start" => result.start,
            "count" => result.total,
            "seed"  => 0,
            "rev"   => 4
      end

      def suite(result)
        log "type"  => "case",
            "label" => result.label,
            "level" => result.level
      end

      def spec(result)
        super
        @result = result
        return passing_spec if result.passing?
        return pending_spec if result.pending?
        failing_spec
      end

      def result(result)
        log "type" => "final",
            "time" => result.elapsed,
            "counts" => {
              "total" => @total,
              "pass"  => @passes.size,
              "fail"  => @failures.size,
              "error" => @errors.size,
              "omit"  => 0,
              "todo"  => @pendings.size
            }
        super
      end

      def error(error)
        @errors << error
      end

      private

      def passing_spec
        log "type"   => "test",
            "status" => "pass",
            "label"  => @result.label
      end

      def pending_spec
        log "type"   => "test",
            "status" => "pending",
            "label"  => @result.label,
            "exception" => {
              "message"   => @result.message
            }
      end

      def failing_spec
        log "type"   => "test",
            "status" => "fail",
            "label"  => @result.label,
            "exception" => {
              "message"   => @result.message,
              "backtrace" => ["#{@result.link}#:0"],
              "file"      => "unknown",
              "line"      => "unknown",
              "source"    => "unknown",
              "snippet"   => {"0" => @result.link},
              "class"     => "Unknown"
            }
      end

      def log(hash)
        STDOUT.print(hash.to_yaml)
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
teabag-0.7.3 lib/teabag/formatters/tap_y_formatter.rb
teabag-0.7.2 lib/teabag/formatters/tap_y_formatter.rb
teabag-0.7.1 lib/teabag/formatters/tap_y_formatter.rb
teabag-0.7.0 lib/teabag/formatters/tap_y_formatter.rb
teabag-0.6.0 lib/teabag/formatters/tap_y_formatter.rb
teabag-0.5.5 lib/teabag/formatters/tap_y_formatter.rb
teabag-0.5.4 lib/teabag/formatters/tap_y_formatter.rb
teabag-0.5.3 lib/teabag/formatters/tap_y_formatter.rb
teabag-0.5.2 lib/teabag/formatters/tap_y_formatter.rb
teabag-0.5.1 lib/teabag/formatters/tap_y_formatter.rb
teabag-0.5.0 lib/teabag/formatters/tap_y_formatter.rb