class Rspeji
Public Class Methods
new(output)
click to toggle source
# File lib/rspeji.rb, line 12 def initialize(output) @emoji = Emoji.new(ENV["EMOJI_SPEC"]) @output = output @output << "Using Rspeji with #{@emoji.selected_set} and:\n" @output << "passed: #{@emoji.passed} / pending: #{@emoji.pending} / failed: #{@emoji.failed}\n" end
Public Instance Methods
close(notification)
click to toggle source
# File lib/rspeji.rb, line 35 def close(notification) @output << "\n" end
dump_failures(notification)
click to toggle source
# File lib/rspeji.rb, line 46 def dump_failures(notification) if notification.failed_examples.length > 0 @output << "\n#{RSpec::Core::Formatters::ConsoleCodes.wrap("FAILING:", :failure)}\n\t" @output << failed_examples_output(notification) end end
dump_pending(notification)
click to toggle source
# File lib/rspeji.rb, line 39 def dump_pending(notification) if notification.pending_examples.length > 0 @output << "\n\n#{RSpec::Core::Formatters::ConsoleCodes.wrap("PENDING:", :pending)}\n\t" @output << notification.pending_examples.map { |example| example.full_description + " - " + example.location }.join("\n\t") end end
dump_summary(notification)
click to toggle source
# File lib/rspeji.rb, line 31 def dump_summary(notification) @output << "\n\nFinished in #{RSpec::Core::Formatters::Helpers.format_duration(notification.duration)}." end
example_failed(notification)
click to toggle source
# File lib/rspeji.rb, line 27 def example_failed(notification) @output << @emoji.failed end
example_passed(notification)
click to toggle source
# File lib/rspeji.rb, line 19 def example_passed(notification) @output << @emoji.passed end
example_pending(notification)
click to toggle source
# File lib/rspeji.rb, line 23 def example_pending(notification) @output << @emoji.pending end
Private Instance Methods
add_spaces(n)
click to toggle source
# File lib/rspeji.rb, line 83 def add_spaces(n) " " * n end
build_examples_output(output)
click to toggle source
Joins all exception messages
# File lib/rspeji.rb, line 64 def build_examples_output(output) output.join("\n\n\t") end
failed_example_output(example)
click to toggle source
Extracts the full_description, location and formats the message of each example exception
# File lib/rspeji.rb, line 70 def failed_example_output(example) full_description = example.full_description location = example.location formatted_message = strip_message_from_whitespace(example.execution_result.exception.message) "#{full_description} - #{location} \n #{formatted_message}" end
failed_examples_output(notification)
click to toggle source
Loops through all of the failed examples and rebuilds the exception message
# File lib/rspeji.rb, line 56 def failed_examples_output(notification) failed_examples_output = notification.failed_examples.map do |example| failed_example_output example end build_examples_output(failed_examples_output) end
strip_message_from_whitespace(msg)
click to toggle source
Removes whitespace from each of the exception message lines and reformats it
# File lib/rspeji.rb, line 79 def strip_message_from_whitespace(msg) msg.split("\n").map(&:strip).join("\n#{add_spaces(10)}") end