Module: RspecInContext::Formatters::DocumentationFormatterPatch

Defined in:
lib/rspec_in_context/formatters/documentation_formatter_patch.rb

Overview

Prepended onto RSpec::Core::Formatters::DocumentationFormatter to hide the anonymous context wrappers that silent in_context creates.

Without this patch, each silent in_context adds a blank line and an extra indentation level to –format documentation output.

Instance Method Summary collapse

Instance Method Details

#example_group_finished(notification) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/rspec_in_context/formatters/documentation_formatter_patch.rb', line 25

def example_group_finished(notification)
  group = notification.group
  if group.[:rspec_in_context_silent] == true &&
       group.description.strip.empty?
    return
  end

  super
end

#example_group_started(notification) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rspec_in_context/formatters/documentation_formatter_patch.rb', line 11

def example_group_started(notification)
  group = notification.group
  # Double check: metadata + empty description.
  # RSpec metadata inherits to children, but notification.group.description
  # returns the group's OWN description (not the inherited/concatenated one).
  # So named sub-contexts (non-empty description) pass through to super normally.
  if group.[:rspec_in_context_silent] == true &&
       group.description.strip.empty?
    return
  end

  super
end