Class: RSpec1

Inherits:
Spec::Runner::Formatter::BaseTextFormatter
  • Object
show all
Includes:
NyanCat::Common
Defined in:
lib/nyan_cat_formatter/rspec1.rb

Constant Summary

Constants included from NyanCat::Common

NyanCat::Common::ERROR, NyanCat::Common::ESC, NyanCat::Common::FAIL, NyanCat::Common::NND, NyanCat::Common::PASS, NyanCat::Common::PASS_ARY, NyanCat::Common::PENDING, NyanCat::Common::VT100_CODES, NyanCat::Common::VT100_CODE_VALUES

Instance Method Summary collapse

Methods included from NyanCat::Common

#ascii_cat, #cat_length, #colors, #console_code_for, #current_width, #dump_progress, #eol, #example_width, #failed_or_pending?, #failure_color, #finished?, #format_duration, #highlight, included, #nyan_cat, #nyan_trail, #padding_width, #pending_color, #progress_lines, #rainbowify, #scoreboard, #success_color, #terminal_width, #tick, #wrap

Instance Method Details

#dump_failure(*args) ⇒ Object



38
39
40
41
# File 'lib/nyan_cat_formatter/rspec1.rb', line 38

def dump_failure(*args)
  output.puts "\e[0;31m"
  super
end

#dump_pendingObject



33
34
35
36
# File 'lib/nyan_cat_formatter/rspec1.rb', line 33

def dump_pending
  output.puts "\e[0;33m"
  super
end

#dump_summary(duration, example_count, failure_count, pending_count) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/nyan_cat_formatter/rspec1.rb', line 43

def dump_summary(duration, example_count, failure_count, pending_count)
  @output.puts "\nYou've Nyaned for #{format_duration(duration)}\n".each_char.map {|c| rainbowify(c)}.join
  summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}"
  summary << ", #{pending_count} pending" if pending_count > 0

  if failure_count == 0
    @output.puts failure_color(summary)
  elsif pending_count > 0
    @output.puts pending_color(summary)
  else
    @output.puts success_color(summary)
  end
  @output.flush
end

#example_failed(example, counter = nil, failure = nil) ⇒ Object



23
24
25
26
27
# File 'lib/nyan_cat_formatter/rspec1.rb', line 23

def example_failed(example, counter = nil, failure = nil)
  super
  @failure_count =+1
  tick FAIL
end

#example_passed(example) ⇒ Object



11
12
13
14
15
# File 'lib/nyan_cat_formatter/rspec1.rb', line 11

def example_passed(example)
  super
  @passing_count += 1
  tick PASS
end

#example_pending(example, message = nil) ⇒ Object



17
18
19
20
21
# File 'lib/nyan_cat_formatter/rspec1.rb', line 17

def example_pending(example, message = nil)
  super
  @pending_count =+1
  tick PENDING
end

#start(example_count) ⇒ Object



4
5
6
7
8
9
# File 'lib/nyan_cat_formatter/rspec1.rb', line 4

def start(example_count)
  super(example_count)
  @example_count = example_count
  @current = @color_index = @passing_count = @failure_count = @pending_count = 0
  @example_results = []
end

#start_dumpObject



29
30
31
# File 'lib/nyan_cat_formatter/rspec1.rb', line 29

def start_dump
  @current = @example_count
end