Class: YARD::Handlers::Cucumber::FeatureHandler
- Defined in:
- lib/yard/handlers/cucumber/feature_handler.rb
Constant Summary collapse
- @@step_definitions =
nil
- @@step_transforms =
nil
Instance Method Summary collapse
-
#cache(type) ⇒ Object
Store all comparable items with their compare_value as the key and the item as the value - Reject any compare values that contain escapes #{} as that means they have unpacked constants.
- #match_step_to_step_definition_and_transforms(step) ⇒ Object
- #process ⇒ Object
- #process_scenario(scenario) ⇒ Object
- #process_step(step) ⇒ Object
Methods inherited from Base
Instance Method Details
#cache(type) ⇒ Object
Store all comparable items with their compare_value as the key and the item as the value
-
Reject any compare values that contain escapes #{} as that means they have unpacked constants
50 51 52 53 54 55 |
# File 'lib/yard/handlers/cucumber/feature_handler.rb', line 50 def cache(type) YARD::Registry.all(type).inject({}) do |hash,item| hash[item.regex] = item if item.regex hash end end |
#match_step_to_step_definition_and_transforms(step) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/yard/handlers/cucumber/feature_handler.rb', line 67 def match_step_to_step_definition_and_transforms(step) @@step_definitions.each do |stepdef,stepdef_object| stepdef_matches = step.value.match(stepdef) if stepdef_matches step.definition = stepdef_object stepdef_matches[-1..1].each do |match| @@step_transforms.each do |steptrans,steptransform_object| if steptrans.match(match) step.transforms << steptransform_object steptransform_object.steps << step end end end # Step has been matched to step definition and step transforms break end end end |
#process ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/yard/handlers/cucumber/feature_handler.rb', line 11 def process # Create a cache of all of the step definitions and the step transforms @@step_definitions = cache(:stepdefinition) unless @@step_definitions @@step_transforms = cache(:steptransform) unless @@step_transforms 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 #log.info "Processing Scenario: #{scenario.value}" 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.debug "\n#{exception}\n#{exception.backtrace.join("\n")}\n" end |
#process_scenario(scenario) ⇒ Object
58 59 60 |
# File 'lib/yard/handlers/cucumber/feature_handler.rb', line 58 def process_scenario(scenario) scenario.steps.each {|step| process_step(step) } end |
#process_step(step) ⇒ Object
62 63 64 65 |
# File 'lib/yard/handlers/cucumber/feature_handler.rb', line 62 def process_step(step) match_step_to_step_definition_and_transforms(step) end |