Sha256: ea3d8a7058ead9508d9e51e815cdb290a9279e4c0c3537c25388f3d619bb5aaf

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 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'

module Generative
  class Formatter < 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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
generative-0.2.0.pre2 lib/generative/formatters.rb
generative-0.2.0.pre1 lib/generative/formatters.rb