Class: Generative::Formatter

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

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Formatter

Returns a new instance of Formatter.



28
29
30
# File 'lib/generative/formatters.rb', line 28

def initialize(output)
  super
end

Instance Method Details

#example_failed(notification) ⇒ Object



72
73
74
75
76
77
78
79
80
# File 'lib/generative/formatters.rb', line 72

def example_failed(notification)
  example = notification.example

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

  super
end

#example_group_started(notification) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/generative/formatters.rb', line 32

def example_group_started(notification)
  example_group = notification.group

  @example_group = example_group

  output.puts if @group_level == 0

  if generative?(example_group)
    group_description = "#{example_group.description} (generative)"
    output.puts "#{current_indentation}#{detail_color(group_description)}"

    @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(notification) ⇒ Object



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

def example_passed(notification)
  example = notification.example

  return if generative?(example)

  super
end

#example_pending(notification) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/generative/formatters.rb', line 64

def example_pending(notification)
  example = notification.example

  return if generative?(example)

  super
end