Class: Generative

Inherits:
RSpec::Core::Formatters::DocumentationFormatter
  • Object
show all
Defined in:
lib/generative/formatters.rb

Constant Summary collapse

ORDERING =
->(examples) {
  number_of_examples = ENV.fetch('GENERATIVE_COUNT', '1').to_i
  examples * number_of_examples
}

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Generative

Returns a new instance of Generative.



18
19
20
# File 'lib/generative/formatters.rb', line 18

def initialize(output)
  super(output)
end

Instance Method Details

#example_failed(example) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/generative/formatters.rb', line 55

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

  super(example)
end

#example_group_started(example_group) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/generative/formatters.rb', line 22

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

#example_passed(example) ⇒ Object



43
44
45
46
47
# File 'lib/generative/formatters.rb', line 43

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

  super(example)
end

#example_pending(example) ⇒ Object



49
50
51
52
53
# File 'lib/generative/formatters.rb', line 49

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

  super(example)
end