Class: LegacyRSpecItHandler

Inherits:
YARD::Handlers::Ruby::Legacy::Base
  • Object
show all
Defined in:
lib/yard-rspec/legacy.rb

Constant Summary collapse

MATCH =
/\Ait\s+['"](.+?)['"]\s+(do|\{)/

Instance Method Summary collapse

Instance Method Details

#processObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/yard-rspec/legacy.rb', line 19

def process
  example_name                 = statement.tokens.to_s[MATCH, 1]
  object_names                 = example_name.scan(/\[([^\]]+)\]/)
  example_name_without_objects = example_name.gsub(/\[.+\]/, '').strip

  return if object_names.empty?

  object_names.each do |object_name|
    obj = P(object_name)
    next if obj.is_a?(Proxy)
    
    (obj[:specifications] ||= []) << {
      :name => example_name_without_objects,
      :file => parser.file,
      :line => statement.line,
      :source => statement.block.to_s
    }
  end
end