class RainbowDocumentation

A reinterpretation of the documentation formatter with more character

Automates versioning for gem releases

Constants

COLOR
RELEASE_DATE
TEST_COLOR
VERSION

Public Class Methods

new(output) click to toggle source
Calls superclass method
# File lib/rainbow_documentation.rb, line 29
def initialize(output)
  super
  @output = output
  @group_level = 0
end

Public Instance Methods

example_failed(failure) click to toggle source
# File lib/rainbow_documentation.rb, line 52
def example_failed(failure)
  @output.puts failure_output(failure.example, failure.example.execution_result.exception)
end
example_group_finished(_notification) click to toggle source
# File lib/rainbow_documentation.rb, line 40
def example_group_finished(_notification)
  @group_level -= 1
end
example_group_started(notification) click to toggle source
# File lib/rainbow_documentation.rb, line 35
def example_group_started(notification)
  @output.puts wrap("#{current_indentation}#{notification.group.description.strip}", COLOR[@group_level % 6])
  @group_level += 1
end
example_passed(passed) click to toggle source
# File lib/rainbow_documentation.rb, line 44
def example_passed(passed)
  @output.puts passed_output(passed.example)
end
example_pending(pending) click to toggle source
# File lib/rainbow_documentation.rb, line 48
def example_pending(pending)
  @output.puts pending_output(pending.example, pending.example.execution_result.pending_message)
end

Private Instance Methods

current_indentation() click to toggle source
# File lib/rainbow_documentation.rb, line 75
def current_indentation
  (' ' * 2) * @group_level
end
failure_output(example, _exception) click to toggle source
# File lib/rainbow_documentation.rb, line 66
def failure_output(example, _exception)
  wrap("#{current_indentation}#{example.description.strip} (FAILED - #{next_failure_index})", TEST_COLOR[:fail])
end
next_failure_index() click to toggle source
# File lib/rainbow_documentation.rb, line 70
def next_failure_index
  @next_failure_index ||= 0
  @next_failure_index += 1
end
passed_output(example) click to toggle source
# File lib/rainbow_documentation.rb, line 58
def passed_output(example)
  wrap("#{current_indentation}#{example.description.strip}", TEST_COLOR[:success])
end
pending_output(example, message) click to toggle source
# File lib/rainbow_documentation.rb, line 62
def pending_output(example, message)
  wrap("#{current_indentation}#{example.description.strip} (PENDING: #{message})", TEST_COLOR[:pending])
end
wrap(text, code) click to toggle source
# File lib/rainbow_documentation.rb, line 79
def wrap(text, code)
  if RSpec.configuration.color_enabled?
    "\e[#{code}m#{text}\e[0m"
  else
    text
  end
end