class Lucian::CustomFormatter
Public Class Methods
new(output)
click to toggle source
# File lib/lucian/custom_formatter.rb, line 8 def initialize output @output = output end
Public Instance Methods
close(notification)
click to toggle source
# File lib/lucian/custom_formatter.rb, line 42 def close notification @output << "\n" end
dump_failures(notification)
click to toggle source
# File lib/lucian/custom_formatter.rb, line 31 def dump_failures notification if notification.failed_examples.length > 0 @output << "\n#{RSpec::Core::Formatters::ConsoleCodes.wrap("FAILING:", :failure)}\n" @output << failed_examples_output(notification) end end
dump_pending(notification)
click to toggle source
# File lib/lucian/custom_formatter.rb, line 24 def dump_pending notification if notification.pending_examples.length > 0 @output << "\n\n#{RSpec::Core::Formatters::ConsoleCodes.wrap("PENDING:", :pending)}\n" @output << notification.pending_examples.map {|example| "|=:" + example.full_description + ":|-|:" + example.location + ":=|" }.join("\n") end end
dump_summary(notification)
click to toggle source
# File lib/lucian/custom_formatter.rb, line 38 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/lucian/custom_formatter.rb, line 16 def example_failed notification @output << RSpec::Core::Formatters::ConsoleCodes.wrap("\nFAILED", :failure) end
example_passed(notification)
click to toggle source
# File lib/lucian/custom_formatter.rb, line 12 def example_passed notification @output << RSpec::Core::Formatters::ConsoleCodes.wrap("\nPASSED", :success) end
example_pending(notification)
click to toggle source
# File lib/lucian/custom_formatter.rb, line 20 def example_pending notification @output << RSpec::Core::Formatters::ConsoleCodes.wrap("\nPENDED", :pending) end
Private Instance Methods
add_spaces(n)
click to toggle source
# File lib/lucian/custom_formatter.rb, line 70 def add_spaces n " " * n end
build_examples_output(output)
click to toggle source
# File lib/lucian/custom_formatter.rb, line 55 def build_examples_output output output.join("\n\n") end
failed_example_output(example)
click to toggle source
# File lib/lucian/custom_formatter.rb, line 59 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}:|-|:#{formatted_message}:=|" end
failed_examples_output(notification)
click to toggle source
# File lib/lucian/custom_formatter.rb, line 48 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
# File lib/lucian/custom_formatter.rb, line 66 def strip_message_from_whitespace msg msg.split("\n").map(&:strip).join("\n") end