Class: YARD::Handlers::Ruby::StepDefinitionHandler
- Inherits:
-
Base
- Object
- Base
- YARD::Handlers::Ruby::StepDefinitionHandler
- Defined in:
- lib/yard/handlers/step_definition_handler.rb
Overview
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`:
Class Method Summary collapse
- .custom_step_definitions ⇒ Object
- .custom_step_definitions_defined? ⇒ Boolean
- .default_step_definitions ⇒ Object
- .generate_unique_id ⇒ Object
- .step_definitions ⇒ Object
Instance Method Summary collapse
- #pending_command_statement?(line) ⇒ Boolean
- #pending_keyword ⇒ Object
- #pending_keyword_used?(block) ⇒ Boolean
- #step_definition_name ⇒ Object
- #step_transform_namespace ⇒ Object
Class Method Details
.custom_step_definitions ⇒ Object
26 27 28 |
# File 'lib/yard/handlers/step_definition_handler.rb', line 26 def self.custom_step_definitions YARD::Config.["yard-cucumber"]["language"]["step_definitions"] end |
.custom_step_definitions_defined? ⇒ Boolean
30 31 32 33 34 |
# File 'lib/yard/handlers/step_definition_handler.rb', line 30 def self.custom_step_definitions_defined? YARD::Config.["yard-cucumber"] and YARD::Config.["yard-cucumber"]["language"] and YARD::Config.["yard-cucumber"]["language"]["step_definitions"] end |
.default_step_definitions ⇒ Object
22 23 24 |
# File 'lib/yard/handlers/step_definition_handler.rb', line 22 def self.default_step_definitions [ "When", "Given", "And", "Then" ] end |
.generate_unique_id ⇒ Object
82 83 84 |
# 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 ⇒ Object
36 37 38 39 40 41 42 |
# 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 |
Instance Method Details
#pending_command_statement?(line) ⇒ Boolean
65 66 67 |
# 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 ⇒ Object
61 62 63 |
# File 'lib/yard/handlers/step_definition_handler.rb', line 61 def pending_keyword "pending" end |
#pending_keyword_used?(block) ⇒ Boolean
69 70 71 72 |
# 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 ⇒ Object
78 79 80 |
# 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 ⇒ Object
74 75 76 |
# File 'lib/yard/handlers/step_definition_handler.rb', line 74 def step_transform_namespace YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE end |