Class: RSpecDocumentation::ParsedDocument

Inherits:
Object
  • Object
show all
Includes:
Paintbrush
Defined in:
lib/rspec_documentation/parsed_document.rb

Overview

A parsed Markdown file, provides matched RSpec examples from the document and their location.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document, path:) ⇒ ParsedDocument

Returns a new instance of ParsedDocument.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rspec_documentation/parsed_document.rb', line 10

def initialize(document, path:)
  @document = Kramdown::Document.new(
    document,
    toc_levels: 2...6,
    input: 'GFM',
    syntax_highlighter: 'rouge',
    auto_ids: true
  )
  @path = path
  @failures = []
end

Instance Attribute Details

#failuresObject (readonly)

Returns the value of attribute failures.



6
7
8
# File 'lib/rspec_documentation/parsed_document.rb', line 6

def failures
  @failures
end

Instance Method Details

#execute_and_substitute_examples!Object



26
27
28
29
30
31
32
33
# File 'lib/rspec_documentation/parsed_document.rb', line 26

def execute_and_substitute_examples!
  print_empty if specs.empty?
  specs.each do |spec|
    spec.run
    process_outcome(spec)
    break if RSpecDocumentation.configuration.fail_fast && !failures.empty?
  end
end

#htmlObject



22
23
24
# File 'lib/rspec_documentation/parsed_document.rb', line 22

def html
  document.to_html_rspec_documentation
end

#specsObject



35
36
37
# File 'lib/rspec_documentation/parsed_document.rb', line 35

def specs
  @specs ||= recursive_specs
end