class ATMOutputFormatter
Public Class Methods
new(output)
click to toggle source
Calls superclass method
# File lib/atm_output_formatter.rb, line 7 def initialize(output) super @group_level = 0 end
Public Instance Methods
example_failed(failure)
click to toggle source
# File lib/atm_output_formatter.rb, line 36 def example_failed(failure) failure_output(failure.example) end
example_group_finished(_notification)
click to toggle source
# File lib/atm_output_formatter.rb, line 23 def example_group_finished(_notification) @group_level -= 1 end
example_group_started(notification)
click to toggle source
# File lib/atm_output_formatter.rb, line 16 def example_group_started(notification) output.puts if @group_level.zero? output.puts "#{current_indentation}#{notification.group.description.strip}" @group_level += 1 end
example_passed(passed)
click to toggle source
# File lib/atm_output_formatter.rb, line 27 def example_passed(passed) passed_output(passed.example) end
example_pending(pending)
click to toggle source
# File lib/atm_output_formatter.rb, line 31 def example_pending(pending) pending_output(pending.example, pending.example.execution_result.pending_message) end
example_started(notification)
click to toggle source
# File lib/atm_output_formatter.rb, line 12 def example_started(notification) notification.example.metadata[:step_index] = 0 end
Private Instance Methods
current_color(status)
click to toggle source
# File lib/atm_output_formatter.rb, line 75 def current_color(status) case status when 'Pass' then :success when 'Fail' then :failure else :pending end end
current_indentation()
click to toggle source
# File lib/atm_output_formatter.rb, line 65 def current_indentation ' ' * @group_level end
failure_output(example)
click to toggle source
# File lib/atm_output_formatter.rb, line 53 def failure_output(example) output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation}#{example.description.strip} " \ "(FAILED - #{next_failure_index})", :failure) format_output(example) unless example.metadata[:steps].nil? end
format_output(example)
click to toggle source
# File lib/atm_output_formatter.rb, line 69 def format_output(example) example.metadata[:steps].each do |step| output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{' ' * (@group_level + 1)}step #{step[:index] + 1}: #{step[:step_name]}", current_color(step[:status])) end end
next_failure_index()
click to toggle source
# File lib/atm_output_formatter.rb, line 60 def next_failure_index @next_failure_index ||= 0 @next_failure_index += 1 end
passed_output(example)
click to toggle source
# File lib/atm_output_formatter.rb, line 42 def passed_output(example) output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation}#{example.description.strip}", :success) format_output(example) if example.metadata.key?(:steps) end
pending_output(example, message)
click to toggle source
# File lib/atm_output_formatter.rb, line 47 def pending_output(example, message) output.puts RSpec::Core::Formatters::ConsoleCodes.wrap("#{current_indentation}#{example.description.strip} " \ "(PENDING: #{message})", :pending) end