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
# File lib/dots_formatter/dots.rb, line 88 def print_progress(example, finish = false) tot = ConsoleCodes.wrap("#{@example_count}", :white) fls = ConsoleCodes.wrap("#{fails}", :failure) suc = ConsoleCodes.wrap("#{@runs - @fails}", :success) png = ConsoleCodes.wrap("#{@pendings}", :pending) current_dur = Time.now - @start_time prev_dur = Time.now - @example_start tim = ConsoleCodes.wrap( "(Running #{Helpers.format_duration current_dur})", :cyan) dot = ConsoleCodes.wrap(" ● ", @fails == 0 ? :success : :failure) if @debug run = ConsoleCodes.wrap(" Just ran: #{example.example.description}, which took ", :cyan) tim2 = ConsoleCodes.wrap(Helpers.format_duration(prev_dur), :red) output.puts " #{dot}#{suc}:#{fls}:#{png}/#{tot}#{dot} #{run}#{tim2}" if finish else all = "\r #{dot}#{suc}:#{fls}:#{png}" all << " / #{tot}#{dot}" all << " #{tim}" if @show_time extra_pixels = @screen_width - 65 run = ConsoleCodes.wrap(" Now running: #{example.example.description[0..extra_pixels]}", :cyan) unless finish all << " #{run}" if @show_description output.print all.ljust(@screen_width + (@show_time? 65 : 25))+"\r" end end
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