Class: RSpecSystem::Formatter

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

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Formatter

Returns a new instance of Formatter.



5
6
7
# File 'lib/rspec-system/formatter.rb', line 5

def initialize(output)
  super(output)
end

Instance Method Details

#example_failed(example) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/rspec-system/formatter.rb', line 34

def example_failed(example)
  super(example)
  msg = example.execution_result[:exception]
  output << "\n" << bold('Result: ') << failure_color('failed') << "\n"
  output << bold("Index: ") << "#{next_failure_index}\n"
  output << bold("Reason:\n") << "#{msg}\n\n"
end

#example_passed(example) ⇒ Object



22
23
24
25
# File 'lib/rspec-system/formatter.rb', line 22

def example_passed(example)
  super(example)
  output << "\n" << bold('Result: ') << success_color('passed') << "\n\n"
end

#example_pending(example) ⇒ Object



27
28
29
30
31
32
# File 'lib/rspec-system/formatter.rb', line 27

def example_pending(example)
  super(example)
  msg = example.execution_result[:pending_message]
  output << "\n" << bold('Result: ') << pending_color('pending') << "\n"
  output << bold("Reason: ") << "#{msg}\n\n"
end

#example_started(example) ⇒ Object



16
17
18
19
20
# File 'lib/rspec-system/formatter.rb', line 16

def example_started(example)
  super(example)
  output << "=================================================================\n\n"
  output << bold("Running test:\n  ") << color(example.full_description, :magenta) << "\n\n"
end

#next_failure_indexObject



42
43
44
45
# File 'lib/rspec-system/formatter.rb', line 42

def next_failure_index
  @next_failure_index ||= 0
  @next_failure_index += 1
end

#start(count) ⇒ Object



9
10
11
12
13
14
# File 'lib/rspec-system/formatter.rb', line 9

def start(count)
  super(count)
  output << "=================================================================\n\n"
  output << bold("Commencing rspec-system tests\n")
  output << bold("Total Test Count: ") << color(count, :cyan) << "\n\n"
end