Class: YARD::Handlers::Cucumber::FeatureHandler
- Defined in:
- lib/yard/handlers/cucumber/feature_handler.rb
Class Method Summary collapse
-
.match_step_to_step_definition_and_placeholders(step) ⇒ Object
Given a step object, attempt to match that step to a step transformation.
- .match_steps_to_step_definitions(statement) ⇒ Object
-
.process_scenario(scenario) ⇒ Object
process a scenario.
-
.process_step(step) ⇒ Object
process a step.
Instance Method Summary collapse
Methods inherited from Base
Class Method Details
.match_step_to_step_definition_and_placeholders(step) ⇒ Object
Given a step object, attempt to match that step to a step transformation
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/yard/handlers/cucumber/feature_handler.rb', line 80 def match_step_to_step_definition_and_placeholders(step) YARD::Registry.all(:stepdefinition).each do |stepdef| stepdef_matches = stepdef.regex.match(step.value) if stepdef_matches step.definition = stepdef # Step has been matched to step definition and step placeholders # TODO: If the step were to match again then we would be able to display ambigous step definitions break end end end |
.match_steps_to_step_definitions(statement) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/yard/handlers/cucumber/feature_handler.rb', line 40 def match_steps_to_step_definitions(statement) if statement # For the background and the scenario, find the steps that have definitions process_scenario(statement.background) if statement.background statement.scenarios.each do |scenario| if scenario.outline? #log.info "Scenario Outline: #{scenario.value}" scenario.scenarios.each_with_index do |example,index| #log.info " * Processing Example #{index + 1}" process_scenario(example) end else process_scenario(scenario) end end else log.warn "Empty feature file. A feature failed to process correctly or contains no feature" end rescue YARD::Handlers::NamespaceMissingError rescue Exception => exception log.error "Skipping feature because an error has occurred." log.error "\n#{exception}\n#{exception.backtrace.join("\n")}\n" end |
.process_scenario(scenario) ⇒ Object
process a scenario
67 68 69 |
# File 'lib/yard/handlers/cucumber/feature_handler.rb', line 67 def process_scenario(scenario) scenario.steps.each {|step| process_step(step) } end |
.process_step(step) ⇒ Object
process a step
72 73 74 |
# File 'lib/yard/handlers/cucumber/feature_handler.rb', line 72 def process_step(step) match_step_to_step_definition_and_placeholders(step) end |
Instance Method Details
#process ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/yard/handlers/cucumber/feature_handler.rb', line 8 def process # # Features have already been created when they were parsed. So there # is no need to process the feature further. Previously this is where # feature steps were matched to step definitions and step definitions # were matched to placeholders. This only worked if the feature # files were were assured to be processed last which was accomplished # by overriding YARD::SourceParser to make it load file in a similar # order as Cucumber. # # As of YARD 0.7.0 this is no longer necessary as there are callbacks # that can be registered after all the files have been loaded. That # callback _after_parse_list_ is defined below and performs the # functionality described above. # end |