Class: YARD::RSpecExamples::ItHandler

Inherits:
Handlers::Ruby::Base
  • Object
show all
Defined in:
lib/yard/rspec_examples/it_handler.rb

Overview

Handler that will set up the method <-> example map

Instance Method Summary collapse

Instance Method Details

#full_example_description(it_description) ⇒ Object



16
17
18
# File 'lib/yard/rspec_examples/it_handler.rb', line 16

def full_example_description(it_description)
  "#{ParserTrace.full_description} #{it_description}"
end

#processObject



8
9
10
11
12
13
14
# File 'lib/yard/rspec_examples/it_handler.rb', line 8

def process
  it_description = statement.parameters.empty? ? '' : statement.parameters.source[1...-1]
  rspec_path_string = full_example_description(it_description)
  RSpecExampleRegistry.example_map[rspec_path_string] = statement.block.source.gsub(/\A\s*do\s*^(.*)end\s*\z/m, '\\1')
                                                          .gsub(/\Ado;\s*(.*)\s*end\z/m, '\\1')
                                                          .gsub(/\A{\s*(.*)\s*}/m, '\\1').rstrip
end