Sha256: 2d8a33edfb5a2cfe198dae2328bf21052273d7dd8ebf6882977e02579ee72102

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

# -*- encoding : utf-8 -*-
# 
require "Bacon_Colored/version"

unless defined?(Bacon)
  require 'bacon'
end

require 'colored'

module Bacon
  module SpecDoxOutput

    def handle_requirement(description)
      error = yield
      color = case error
              when 'FAILED'
                :red
              else
                :yellow
              end 

      mark = error.empty? ? "✓ ".green : "✗ ".send(color)
      print " #{mark}#{description}"

      return puts("") if error.empty?
      puts " [#{error}]".send(color)
    end

    def handle_summary
      specs, reqs, fails, errs = Counter.values_at(:specifications, :requirements, :failed, :errors)
      all_pass = reqs > 1 && (fails == errs) && (errs == 0) 

      print ErrorLog  if Backtraces
      
      print "%d specifications (%d requirements)".send(all_pass ? :green : :to_s ) % [ specs, reqs ]

      if all_pass
        print( ". All pass. ".green )
      else
        print ", "
        print "#{fails} failures".send( fails > 0 ? :red : :to_s )
        print ", "
        print "#{errs} errors".send( errs > 0 ? :yellow : :to_s )
        print ". "
      end
      
      puts 
      puts
    end  
    
  end # === module
end # === module

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Bacon_Colored-0.1.0 lib/Bacon_Colored.rb