Class: Nyan::Formatter

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

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Formatter

Returns a new instance of Formatter.



6
7
8
9
10
11
12
# File 'lib/nyan/formatter.rb', line 6

def initialize(*args)
  super
  @nyan_flight = Nyan::Flight.new
  @still_passing = true
  print cls
  puts "Awaiting Nyan..."
end

Instance Method Details

#dump_backtrace(example) ⇒ Object



37
38
39
40
41
# File 'lib/nyan/formatter.rb', line 37

def dump_backtrace(example)
  format_backtrace(example.execution_result[:exception].backtrace, example).each do |backtrace_info|
    output.puts cyan("         # #{backtrace_info}")
  end
end

#dump_failuresObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/nyan/formatter.rb', line 26

def dump_failures
  return if failed_examples.empty?
  output.puts
  output.puts "Failures:"
  failed_examples.each_with_index do |example, index|
    output.puts
    dump_pending_example_fixed(example, index) || dump_failure(example, index)
    dump_backtrace(example)
  end
end

#example_failed(example) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/nyan/formatter.rb', line 18

def example_failed(example)
  super
  @output.print cls
  @output.print move(0,0)
  @output.puts red("NO NYAN FOR YOU")
  @still_passing = false
end

#example_passed(_) ⇒ Object



14
15
16
# File 'lib/nyan/formatter.rb', line 14

def example_passed(_)
  @nyan_flight.next! if @still_passing
end