Class: RspecKungFuHamster

Inherits:
RSpec::Core::Formatters::BaseTextFormatter
  • Object
show all
Defined in:
lib/rspec_kung_fu_hamster.rb

Constant Summary collapse

KUNG_FU_HAMSTER =
[
  [
    "    ()__()     ",
    "    / o o\\  |  ",
    "   |' =Y=';-|  ",
    "   { \\  / }    ",
    "    mmm mmm    "
],[
    "    ()__()     ",
    "    / o o\\   ; ",
    "   |' =Y=';-/  ",
    "   { \\  / }    ",
    "    mmm mmm    "
],[
    "    ()__()     ",
    "    / o o\\     ",
    "   |' =Y=';----",
    "   { \\  / }    ",
    "    mmm mmm    "
],[
    "    ()__()     ",
    "    / o o\\     ",
    "   |' =Y=';-\\  ",
    "   { \\  / }  \\ ",
    "    mmm mmm    "
],[
    "    ()__()     ",
    "    / o o\\     ",
    "   |' =Y=';----",
    "   { \\  / }    ",
    "    mmm mmm    "
],[
    "    ()__()     ",
    "    / o o\\ \\   ",
    "   |' =Y=';-\\  ",
    "   { \\  / }    ",
    "    mmm mmm    "
]]
DEAD_HAMSTER =
[
  "    ()__()     ",
  "    / X X\\  |  ",
  "   |' =Y=';-|  ",
  "   { \\  / }    ",
  "    mmm mmm    "
]

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ RspecKungFuHamster

:dump_failures



16
17
18
19
# File 'lib/rspec_kung_fu_hamster.rb', line 16

def initialize(output)
  @index = 0
  super(output)
end

Instance Method Details

#example_failed(notification) ⇒ Object



24
25
26
27
# File 'lib/rspec_kung_fu_hamster.rb', line 24

def example_failed(notification)
  output.puts "\e[2J\e[;H" << hamster_and_next.join("\n")
  sleep 0.1
end

#example_passed(notification) ⇒ Object



21
22
23
# File 'lib/rspec_kung_fu_hamster.rb', line 21

def example_passed(notification)
  output.puts "\e[2J\e[;H" << hamster_and_next.join("\n")
end

#hamster_and_nextObject



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

def hamster_and_next
  KUNG_FU_HAMSTER[@index % KUNG_FU_HAMSTER.length].tap { @index += 1 }
end