Sha256: 5bb9b88af4222976ea09e1f5426c177566e27d14e1e352e9f97042c59633bcd0

Contents?: true

Size: 1.57 KB

Versions: 4

Compression:

Stored size: 1.57 KB

Contents

module Teaspoon
  module Formatters

    autoload :DotFormatter,           'teaspoon/formatters/dot_formatter'
    autoload :CleanFormatter,         'teaspoon/formatters/clean_formatter'
    autoload :TapYFormatter,          'teaspoon/formatters/tap_y_formatter'
    autoload :TapFormatter,           'teaspoon/formatters/tap_formatter'
    autoload :SwayzeOrOprahFormatter, 'teaspoon/formatters/swayze_or_oprah_formatter'
    autoload :TeamcityFormatter,      'teaspoon/formatters/teamcity_formatter'

    class BaseFormatter

      attr_accessor :total, :passes, :pendings, :failures, :errors

      def initialize(suite_name = :default)
        @suite_name = suite_name.to_s
        @total    = 0
        @passes   = []
        @pendings = []
        @failures = []
        @errors   = []
      end

      def spec(result)
        @total += 1
        if result.passing?
          @passes << result
        elsif result.pending?
          @pendings << result
        else
          @failures << result
        end
      end

      def result(results)
        log_coverage(results["coverage"])
        return if failures.size == 0
        STDOUT.print("\n")
        raise Teaspoon::Failure if Teaspoon.configuration.fail_fast
      end

      # Exceptions come from startup errors in the server
      def exception(exception = {})
        raise Teaspoon::RunnerException
      end

      def suppress_logs?
        false
      end

      private

      def log_coverage(data)
        return if data.blank? || suppress_logs?
        STDOUT.print(Teaspoon::Coverage.new(data).reports)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
teaspoon-0.7.7 lib/teaspoon/formatters/base_formatter.rb
teaspoon-0.7.6 lib/teaspoon/formatters/base_formatter.rb
teaspoon-0.7.5 lib/teaspoon/formatters/base_formatter.rb
teaspoon-0.7.4 lib/teaspoon/formatters/base_formatter.rb