Parent

Class/Module Index [+]

Quicksearch

RSpec::Core::Formatters::BaseTextFormatter

Public Instance Methods

close() click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 84
def close
  output.close if IO === output && output != $stdout
end
colorise_summary(summary) click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 24
def colorise_summary(summary)
  if failure_count == 0
    if pending_count > 0
      yellow(summary)
    else
      green(summary)
    end
  else
    red(summary)
  end
end
dump_commands_to_rerun_failed_examples() click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 45
def dump_commands_to_rerun_failed_examples
  return if failed_examples.empty?
  output.puts
  output.puts("Failed examples:")
  output.puts

  failed_examples.each do |example|
    output.puts(red("rspec #{BaseFormatter::relative_path(example.location)}") + " " + cyan("# #{example.full_description}"))
  end
end
dump_failures() click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 13
def dump_failures
  return if failed_examples.empty?
  output.puts
  output.puts "Failures:"
  failed_examples.each_with_index do |example, index|
    output.puts
    dump_pending_example_fixed(example, index) || dump_failure(example, index)
    dump_backtrace(example)
  end
end
dump_pending() click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 72
def dump_pending
  unless pending_examples.empty?
    output.puts
    output.puts "Pending:"
    pending_examples.each do |pending_example|
      output.puts yellow("  #{pending_example.full_description}")
      output.puts cyan("    # #{pending_example.execution_result[:pending_message]}")
      output.puts cyan("    # #{format_caller(pending_example.location)}")
    end
  end
end
dump_profile() click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 56
def dump_profile
  sorted_examples = examples.sort_by { |example| example.execution_result[:run_time] }.reverse.first(10)
  output.puts "\nTop #{sorted_examples.size} slowest examples:\n"
  sorted_examples.each do |example|
    output.puts "  #{example.full_description}"
    output.puts cyan("    #{red(format_seconds(example.execution_result[:run_time]))} #{red("seconds")} #{format_caller(example.location)}")
  end
end
dump_summary(duration, example_count, failure_count, pending_count) click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 36
def dump_summary(duration, example_count, failure_count, pending_count)
  super(duration, example_count, failure_count, pending_count)
  # Don't print out profiled info if there are failures, it just clutters the output
  dump_profile if profile_examples? && failure_count == 0
  output.puts "\nFinished in #{format_seconds(duration)} seconds\n"
  output.puts colorise_summary(summary_line(example_count, failure_count, pending_count))
  dump_commands_to_rerun_failed_examples
end
message(message) click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 9
def message(message)
  output.puts message
end
summary_line(example_count, failure_count, pending_count) click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 65
def summary_line(example_count, failure_count, pending_count)
  summary = pluralize(example_count, "example")
  summary << ", " << pluralize(failure_count, "failure")
  summary << ", #{pending_count} pending" if pending_count > 0
  summary
end

Protected Instance Methods

blue(text) click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 110
def blue(text)
  color(text, "\e[34m")
end
bold(text) click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 94
def bold(text)
  color(text, "\e[1m")
end
color(text, color_code) click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 90
def color(text, color_code)
  color_enabled? ? "#{color_code}#{text}\e[0m" : text
end
cyan(text) click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 118
def cyan(text)
  color(text, "\e[36m")
end
green(text) click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 102
def green(text)
  color(text, "\e[32m")
end
long_padding() click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 130
def long_padding
  '     '
end
magenta(text) click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 114
def magenta(text)
  color(text, "\e[35m")
end
red(text) click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 98
def red(text)
  color(text, "\e[31m")
end
short_padding() click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 126
def short_padding
  '  '
end
white(text) click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 122
def white(text)
  color(text, "\e[37m")
end
yellow(text) click to toggle source
# File lib/rspec/core/formatters/base_text_formatter.rb, line 106
def yellow(text)
  color(text, "\e[33m")
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.