/usr/lib/ruby/1.8/ramaze/spec/helper/pretty_output.rb is in libramaze-ruby1.8 2010.06.18-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | module Bacon
module PrettyOutput
NAME = ''
# store name and run
def handle_specification(name)
NAME.replace name
puts NAME
yield
puts
end
# Core, yields the requirement and outputs problems
def handle_requirement(description)
print "- #{description}\n"
error = yield
unless error.empty?
if defined?(Ramaze::Logging)
puts '', " #{NAME} -- #{description} [FAILED]".center(70, '-'), ''
colors = Ramaze::Logger::Informer::COLORS
until RamazeLogger.history.empty?
tag, line = RamazeLogger.history.shift
out = "%6s | %s" % [tag.to_s, line]
puts out.send(colors[tag])
end
end
general_error
end
end
# Show nicer output on error
def general_error
puts "", ErrorLog
ErrorLog.scan(/^\s*(.*?):(\d+): #{NAME} - (.*?)$/) do
puts "#{ENV['EDITOR'] || 'vim'} #$1 +#$2 # #$3"
end
ErrorLog.replace ''
end
# output summary
def handle_summary
puts
puts "%d tests, %d assertions, %d failures, %d errors" %
Counter.values_at(:specifications, :requirements, :failed, :errors)
end
end
end
if defined?(Ramaze::Logging)
module Ramaze
# Special Logger, stores everything in its history
class SpecLogger
include Ramaze::Logging
include Enumerable
attr_accessor :history
# Create new history
def initialize
@history = []
end
# Yield the history
def each
@history.each{|e| yield(e) }
end
# general log
def log(tag, str)
@history << [tag, str]
end
end
end
module Bacon::PrettyOutput
RamazeLogger = Ramaze::SpecLogger.new
Ramaze::Log.loggers = [RamazeLogger]
end
end
|