# File lib/rspec/core/formatters/base_text_formatter.rb, line 102 102: def close 103: output.close if IO === output && output != $stdout 104: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 24 24: def colorise_summary(summary) 25: if failure_count > 0 26: red(summary) 27: elsif pending_count > 0 28: yellow(summary) 29: else 30: green(summary) 31: end 32: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 43 43: def dump_commands_to_rerun_failed_examples 44: return if failed_examples.empty? 45: output.puts 46: output.puts("Failed examples:") 47: output.puts 48: 49: failed_examples.each do |example| 50: output.puts(red("rspec #{RSpec::Core::Metadata::relative_path(example.location)}") + " " + cyan("# #{example.full_description}")) 51: end 52: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 13 13: def dump_failures 14: return if failed_examples.empty? 15: output.puts 16: output.puts "Failures:" 17: failed_examples.each_with_index do |example, index| 18: output.puts 19: pending_fixed?(example) ? dump_pending_fixed(example, index) : dump_failure(example, index) 20: dump_backtrace(example) 21: end 22: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 79 79: def dump_pending 80: unless pending_examples.empty? 81: output.puts 82: output.puts "Pending:" 83: pending_examples.each do |pending_example| 84: output.puts yellow(" #{pending_example.full_description}") 85: output.puts cyan(" # #{pending_example.execution_result[:pending_message]}") 86: output.puts cyan(" # #{format_caller(pending_example.location)}") 87: if pending_example.execution_result[:exception] && RSpec.configuration.show_failures_in_pending_blocks? 88: dump_failure_info(pending_example) 89: dump_backtrace(pending_example) 90: end 91: end 92: end 93: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 54 54: def dump_profile 55: sorted_examples = examples.sort_by {|example| 56: example.execution_result[:run_time] }.reverse.first(10) 57: 58: total, slows = [examples, sorted_examples].map {|exs| 59: exs.inject(0.0) {|i, e| i + e.execution_result[:run_time] }} 60: 61: time_taken = slows / total 62: percentage = '%.1f' % ((time_taken.nan? ? 0.0 : time_taken) * 100) 63: 64: output.puts "\nTop #{sorted_examples.size} slowest examples (#{format_seconds(slows)} seconds, #{percentage}% of total time):\n" 65: 66: sorted_examples.each do |example| 67: output.puts " #{example.full_description}" 68: output.puts cyan(" #{red(format_seconds(example.execution_result[:run_time]))} #{red("seconds")} #{format_caller(example.location)}") 69: end 70: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 34 34: def dump_summary(duration, example_count, failure_count, pending_count) 35: super(duration, example_count, failure_count, pending_count) 36: # Don't print out profiled info if there are failures, it just clutters the output 37: dump_profile if profile_examples? && failure_count == 0 38: output.puts "\nFinished in #{format_duration(duration)}\n" 39: output.puts colorise_summary(summary_line(example_count, failure_count, pending_count)) 40: dump_commands_to_rerun_failed_examples 41: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 9 9: def message(message) 10: output.puts message 11: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 96 96: def seed(number) 97: output.puts 98: output.puts "Randomized with seed #{number}" 99: output.puts 100: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 72 72: def summary_line(example_count, failure_count, pending_count) 73: summary = pluralize(example_count, "example") 74: summary << ", " << pluralize(failure_count, "failure") 75: summary << ", #{pending_count} pending" if pending_count > 0 76: summary 77: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 128 128: def blue(text) 129: color(text, "\e[34m") 130: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 112 112: def bold(text) 113: color(text, "\e[1m") 114: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 108 108: def color(text, color_code) 109: color_enabled? ? "#{color_code}#{text}\e[0m" : text 110: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 136 136: def cyan(text) 137: color(text, "\e[36m") 138: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 120 120: def green(text) 121: color(text, "\e[32m") 122: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 148 148: def long_padding 149: ' ' 150: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 132 132: def magenta(text) 133: color(text, "\e[35m") 134: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 116 116: def red(text) 117: color(text, "\e[31m") 118: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 144 144: def short_padding 145: ' ' 146: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 158 158: def dump_backtrace(example) 159: format_backtrace(example.execution_result[:exception].backtrace, example).each do |backtrace_info| 160: output.puts cyan("#{long_padding}# #{backtrace_info}") 161: end 162: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 173 173: def dump_failure(example, index) 174: output.puts "#{short_padding}#{index.next}) #{example.full_description}" 175: dump_failure_info(example) 176: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 178 178: def dump_failure_info(example) 179: exception = example.execution_result[:exception] 180: output.puts "#{long_padding}#{red("Failure/Error:")} #{red(read_failed_line(exception, example).strip)}" 181: output.puts "#{long_padding}#{red(exception.class.name << ":")}" unless exception.class.name =~ /RSpec/ 182: exception.message.to_s.split("\n").each { |line| output.puts "#{long_padding} #{red(line)}" } if exception.message 183: if shared_group = find_shared_group(example) 184: dump_shared_failure_info(shared_group) 185: end 186: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 164 164: def dump_pending_fixed(example, index) 165: output.puts "#{short_padding}#{index.next}) #{example.full_description} FIXED" 166: output.puts blue("#{long_padding}Expected pending '#{example.metadata[:execution_result][:pending_message]}' to fail. No Error was raised.") 167: end
# File lib/rspec/core/formatters/base_text_formatter.rb, line 154 154: def format_caller(caller_info) 155: backtrace_line(caller_info.to_s.split(':in `block').first) 156: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.