module Bacon::PrettyOutput

Constants

NAME
RamazeLogger

Public Instance Methods

general_error() click to toggle source

Show nicer output on error

# File lib/ramaze/spec/helper/pretty_output.rb, line 35
def general_error
  puts "", ErrorLog
  ErrorLog.scan(/^\s*(.*?):(\d+): #{NAME} - (.*?)$/) do
    puts "#{ENV['EDITOR'] || 'vim'} #$1 +#$2 # #$3"
  end
  ErrorLog.replace ''
end
handle_requirement(description) { || ... } click to toggle source

Core, yields the requirement and outputs problems

# File lib/ramaze/spec/helper/pretty_output.rb, line 14
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
handle_specification(name) { || ... } click to toggle source

store name and run

# File lib/ramaze/spec/helper/pretty_output.rb, line 6
def handle_specification(name)
  NAME.replace name
                    puts NAME
  yield
                    puts
end
handle_summary() click to toggle source

output summary

# File lib/ramaze/spec/helper/pretty_output.rb, line 44
def handle_summary
        puts
  puts "%d tests, %d assertions, %d failures, %d errors" %
    Counter.values_at(:specifications, :requirements, :failed, :errors)
end