Sha256: ee206fc74de39d9edcd2538f154a76739ca27526cca8738b4011dc05ebe88f7c

Contents?: true

Size: 1.78 KB

Versions: 11

Compression:

Stored size: 1.78 KB

Contents

#
# Finds and processes all the step definitions defined in the ruby source
# code. By default the english gherkin language will be parsed.
# 
# To override the language you can define the step definitions in the YARD 
# configuration file `~./yard/config`:
# 
# @example `~/.yard/config` with LOLCatz step definitions
# 
#     :"yard-cucumber": 
#       language: 
#         step_definitions: [ 'WEN', 'I CAN HAZ', 'AN', 'DEN' ]
# 
# @example `~/.yard/config` with French step definitions
# 
#     :"yard-cucumber": 
#       language: 
#         step_definitions: [ 'Soit', 'Etantdonné', 'Lorsque', 'Lorsqu', 'Alors', 'Et' ]
# 
class YARD::Handlers::Ruby::StepDefinitionHandler < YARD::Handlers::Ruby::Base
  
  #
  # By default the english gherkin language will be parsed, however, if the
  # YARD configuration file `~./yard/config` defines different step definition
  # handlers those are used.
  # 
  # 
  if YARD::Config.options["yard-cucumber"] and 
    YARD::Config.options["yard-cucumber"]["language"] and
    YARD::Config.options["yard-cucumber"]["language"]["step_definitions"]
    
    YARD::Config.options["yard-cucumber"]["language"]["step_definitions"].each do |step_word|
      handles method_call(step_word.to_sym)
    end
    
  else
    handles method_call(:When),method_call(:Given),method_call(:And),method_call(:Then)
  end
  
  
  @@unique_name = 0
  
  process do
    @@unique_name += 1

    instance = YARD::CodeObjects::StepDefinitionObject.new(YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE,"step_definition#{@@unique_name}") do |o| 
      o.source = statement.source
      o.comments = statement.comments
      o.keyword = statement[0].source
      o.value = statement[1].source
    end

    obj = register instance
    parse_block(statement[2],:owner => obj)
    
  end
  
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
yard-cucumber-2.2.2 lib/yard/handlers/step_definition_handler.rb
yard-cucumber-2.2.1 lib/yard/handlers/step_definition_handler.rb
yard-cucumber-2.2.0 lib/yard/handlers/step_definition_handler.rb
yard-cucumber-2.1.7 lib/yard/handlers/step_definition_handler.rb
yard-cucumber-2.1.6 lib/yard/handlers/step_definition_handler.rb
yard-cucumber-2.1.5 lib/yard/handlers/step_definition_handler.rb
yard-cucumber-2.1.4 lib/yard/handlers/step_definition_handler.rb
yard-cucumber-2.1.3 lib/yard/handlers/step_definition_handler.rb
yard-cucumber-2.1.2 lib/yard/handlers/step_definition_handler.rb
yard-cucumber-2.1.1 lib/yard/handlers/step_definition_handler.rb
yard-cucumber-2.1.0 lib/yard/handlers/step_definition_handler.rb