Sha256: aa36e88ce58b3d9ade3be18c815c203a2690b79258a7ede5ad2fdf888cd65912

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require 'rspec/core/formatters/progress_formatter'

class RSpec::Core::Formatters::ProgressFormatter
  def example_passed(example)
    super(example)

    if example.metadata[:generative]
      output.print detail_color('.')
    else
      output.print success_color('.')
    end
  end
end

require 'rspec/core/formatters/documentation_formatter'

class Generative < RSpec::Core::Formatters::DocumentationFormatter
  def initialize(output)
    super(output)
  end

  def example_group_started(example_group)
    @example_group = example_group

    output.puts if @group_level == 0

    if generative?(example_group)
      output.puts "#{current_indentation}#{detail_color('generative')}"

      @group_level += 1
      example_group.examples.each do |example|
        output.puts "#{current_indentation}#{detail_color(example.description)}"
      end

      @group_level -= 1
    else
      output.puts "#{current_indentation}#{example_group.description.strip}"
    end

    @group_level += 1
  end

  def example_passed(example)
    return if generative?(example)

    super(example)
  end

  def example_pending(example)
    return if generative?(example)

    super(example)
  end

  def example_failed(example)
    if generative?(example)
      RSpec.wants_to_quit = true
      return
    end

    super(example)
  end

  private

  def generative?(example)
    example.metadata[:generative]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
generative-0.0.1 lib/generative/formatters.rb