Sha256: af026714d990f8c7dfddd6643e2b5c2faffb71bdce7336e6a2d91b226f144fc4
Contents?: true
Size: 1.71 KB
Versions: 6
Compression:
Stored size: 1.71 KB
Contents
module Micronaut module Formatters class DocumentationFormatter < BaseTextFormatter attr_reader :previous_nested_behaviours def initialize super @previous_nested_behaviours = [] end def add_behaviour(behaviour) super described_behaviour_chain.each_with_index do |nested_behaviour, i| unless nested_behaviour == previous_nested_behaviours[i] at_root_level = (i == 0) desc_or_name = at_root_level ? nested_behaviour.name : nested_behaviour.description output.puts if at_root_level output.puts "#{' ' * i}#{desc_or_name}" end end @previous_nested_behaviours = described_behaviour_chain end def example_failed(example, exception) super expectation_not_met = exception.is_a?(Micronaut::Expectations::ExpectationNotMetError) message = if expectation_not_met "#{current_indentation}#{example.description} (FAILED)" else "#{current_indentation}#{example.description} (ERROR)" end output.puts(expectation_not_met ? red(message) : magenta(message)) output.flush end def example_passed(example) super output.puts green("#{current_indentation}#{example.description}") output.flush end def example_pending(example, message) super output.puts yellow("#{current_indentation}#{example.description} (PENDING: #{message})") output.flush end def current_indentation ' ' * previous_nested_behaviours.size end def described_behaviour_chain behaviour.ancestors end end end end
Version data entries
6 entries across 6 versions & 1 rubygems