class RSpec::Core::Formatters::DotsFormatter

Attributes

debug[RW]
example_start[RW]
fails[RW]
passes[RW]
pendings[RW]
runs[RW]
screen_width[RW]
show_description[RW]
show_time[RW]
start_time[RW]

Public Class Methods

new(output) click to toggle source
Calls superclass method
# File lib/dots_formatter/dots.rb, line 23
def initialize(output)
  @passes = 0
  @fails = 0
  @runs = 0
  @pendings = 0
  @screen_width = `tput cols`.to_i - 1
  @debug = false
  @show_time = @screen_width > 50
  @show_description = @screen_width > 80
  super(output)
end

Public Instance Methods

dump_failures(notification) click to toggle source
# File lib/dots_formatter/dots.rb, line 83
def dump_failures(notification)
   output.puts
   output.puts notification.fully_formatted_failed_examples if @fails > 0
end
dump_summary(summary) click to toggle source
# File lib/dots_formatter/dots.rb, line 68
def dump_summary(summary)
  output.puts
  output.puts
  colour = (@fails == 0)? :success : :failure
  max = [50, @screen_width - 1].min

  output.puts ConsoleCodes.wrap("┌" + "-".ljust(max,"-")  + "┐", colour)
  output.puts ConsoleCodes.wrap("│   #{summary.example_count} test#{summary.example_count == 1? '' : 's'}".ljust(max) + " |", colour)
  output.puts ConsoleCodes.wrap("|   #{@fails} failure#{@fails == 1? '' : 's'}".ljust(max) + " |", colour)
  output.puts ConsoleCodes.wrap("|   Ran in #{Helpers.format_duration summary.duration}".ljust(max) + " |", colour)
  output.puts ConsoleCodes.wrap("└" + "-".ljust(max,"-")  + "┘", colour)
  output.puts
  output.puts summary.colorized_rerun_commands if @fails > 0
end
example_failed(example) click to toggle source
# File lib/dots_formatter/dots.rb, line 58
def example_failed(example)
  @fails += 1
  @runs += 1
  failure = ConsoleCodes.wrap("\r Failed example: ", :failure) +
            ConsoleCodes.wrap(example.example.full_description, :white)
  output.puts failure[0..@screen_width].ljust(@screen_width) unless @debug
  print_progress(example, true)
end
example_passed(example) click to toggle source
# File lib/dots_formatter/dots.rb, line 52
def example_passed(example)
  @runs += 1
  @passes += 1
  print_progress(example, true)
end
example_pending(example) click to toggle source
# File lib/dots_formatter/dots.rb, line 46
def example_pending(example)
  @runs += 1
  @pendings += 1
  print_progress(example, true)
end
example_started(example) click to toggle source
# File lib/dots_formatter/dots.rb, line 41
def example_started(example)
  @example_start = Time.now
  print_progress(example)
end
print_progress(example, finish = false) click to toggle source
start(notification) click to toggle source
# File lib/dots_formatter/dots.rb, line 35
def start(notification)
  @start_time = Time.now
  @example_count = notification.count
  output.puts #new line
end