Sha256: 74824846d8e8c5e1492ac626e2809b72d4a5e54cceafd008c40da16d20f5e700

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 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
    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.1.0 lib/generative/formatters.rb