Class: RSpec::Core::Formatters::DocumentationFormatter

Inherits:
BaseTextFormatter show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/documentation_formatter.rb

Instance Attribute Summary

Attributes inherited from BaseFormatter

#example_group, #output

Instance Method Summary collapse

Methods inherited from BaseTextFormatter

#close, #dump_failures, #dump_pending, #dump_summary, #seed

Methods inherited from BaseFormatter

#close, #start

Constructor Details

#initialize(output) ⇒ DocumentationFormatter

Returns a new instance of DocumentationFormatter.



12
13
14
15
16
17
18
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/documentation_formatter.rb', line 12

def initialize(output)
  super
  @group_level = 0

  @example_running = false
  @messages = []
end

Instance Method Details

#example_failed(failure) ⇒ Object



50
51
52
53
54
55
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/documentation_formatter.rb', line 50

def example_failed(failure)
  output.puts failure_output(failure.example)

  flush_messages
  @example_running = false
end

#example_group_finished(_notification) ⇒ Object



31
32
33
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/documentation_formatter.rb', line 31

def example_group_finished(_notification)
  @group_level -= 1 if @group_level > 0
end

#example_group_started(notification) ⇒ Object



24
25
26
27
28
29
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/documentation_formatter.rb', line 24

def example_group_started(notification)
  output.puts if @group_level == 0
  output.puts "#{current_indentation}#{notification.group.description.strip}"

  @group_level += 1
end

#example_passed(passed) ⇒ Object



35
36
37
38
39
40
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/documentation_formatter.rb', line 35

def example_passed(passed)
  output.puts passed_output(passed.example)

  flush_messages
  @example_running = false
end

#example_pending(pending) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/documentation_formatter.rb', line 42

def example_pending(pending)
  output.puts pending_output(pending.example,
                             pending.example.execution_result.pending_message)

  flush_messages
  @example_running = false
end

#example_started(_notification) ⇒ Object



20
21
22
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/documentation_formatter.rb', line 20

def example_started(_notification)
  @example_running = true
end

#message(notification) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters/documentation_formatter.rb', line 57

def message(notification)
  if @example_running
    @messages << notification.message
  else
    output.puts "#{current_indentation}#{notification.message}"
  end
end