class YARD::Handlers::Ruby::StepDefinitionHandler
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' ]
Public Class Methods
custom_step_definitions()
click to toggle source
# File lib/yard/handlers/step_definition_handler.rb, line 26 def self.custom_step_definitions YARD::Config.options["yard-cucumber"]["language"]["step_definitions"] end
custom_step_definitions_defined?()
click to toggle source
# File lib/yard/handlers/step_definition_handler.rb, line 30 def self.custom_step_definitions_defined? YARD::Config.options["yard-cucumber"] and YARD::Config.options["yard-cucumber"]["language"] and YARD::Config.options["yard-cucumber"]["language"]["step_definitions"] end
default_step_definitions()
click to toggle source
# File lib/yard/handlers/step_definition_handler.rb, line 22 def self.default_step_definitions [ "When", "Given", "And", "Then" ] end
generate_unique_id()
click to toggle source
# File lib/yard/handlers/step_definition_handler.rb, line 82 def self.generate_unique_id @step_definition_count = @step_definition_count.to_i + 1 end
step_definitions()
click to toggle source
# File lib/yard/handlers/step_definition_handler.rb, line 36 def self.step_definitions if custom_step_definitions_defined? custom_step_definitions else default_step_definitions end end
Public Instance Methods
pending_command_statement?(line)
click to toggle source
# File lib/yard/handlers/step_definition_handler.rb, line 65 def pending_command_statement?(line) (line.type == :command || line.type == :vcall) && line.first.source == pending_keyword end
pending_keyword()
click to toggle source
# File lib/yard/handlers/step_definition_handler.rb, line 61 def pending_keyword "pending" end
pending_keyword_used?(block)
click to toggle source
# File lib/yard/handlers/step_definition_handler.rb, line 69 def pending_keyword_used?(block) code_in_block = block.last code_in_block.find { |line| pending_command_statement?(line) } end
step_definition_name()
click to toggle source
# File lib/yard/handlers/step_definition_handler.rb, line 78 def step_definition_name "step_definition#{self.class.generate_unique_id}" end
step_transform_namespace()
click to toggle source
# File lib/yard/handlers/step_definition_handler.rb, line 74 def step_transform_namespace YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE end