Class: CukeSniffer::Feature
- Inherits:
-
FeatureRuleTarget
- Object
- RuleTarget
- FeatureRuleTarget
- CukeSniffer::Feature
- Defined in:
- lib/cuke_sniffer/feature.rb
Overview
- Author
-
Robert Cochran ([email protected])
- Copyright
-
Copyright © 2013 Robert Cochran
- License
-
Distributes under the MIT License
Handles feature files and disassembles and evaluates its components. Extends CukeSniffer::FeatureRulesEvaluator
Constant Summary collapse
- SCENARIO_TITLE_REGEX =
:nodoc:
/#{COMMENT_REGEX}#{SCENARIO_TITLE_STYLES}(?<name>.*)/
Constants included from RuleConfig
RuleConfig::ERROR, RuleConfig::FATAL, RuleConfig::INFO, RuleConfig::RULES, RuleConfig::WARNING
Constants included from Constants
Constants::COMMENT_REGEX, Constants::DATE_REGEX, Constants::DEFAULT_OUTPUT_FILE_NAME, Constants::FILE_IGNORE_LIST, Constants::HOOK_REGEX, Constants::HOOK_STYLES, Constants::MARKUP_SOURCE, Constants::SCENARIO_TITLE_STYLES, Constants::STEP_DEFINITION_REGEX, Constants::STEP_REGEX, Constants::STEP_STYLES, Constants::TAG_REGEX, Constants::THRESHOLDS
Instance Attribute Summary collapse
-
#background ⇒ Object
Scenario: The background of a Feature, created as a Scenario object.
-
#feature_lines ⇒ Object
String array: A list of all the lines in a feature file.
-
#scenarios ⇒ Object
Scenario array: A list of all scenarios contained in a feature file.
-
#scenarios_score ⇒ Object
int: Total score from all of the scenarios contained in the feature.
-
#total_score ⇒ Object
int: Total score of the feature and its scenarios.
Attributes inherited from FeatureRuleTarget
Attributes inherited from RuleTarget
#location, #rules_hash, #score
Instance Method Summary collapse
-
#==(comparison_object) ⇒ Object
:nodoc:.
-
#initialize(file_name) ⇒ Feature
constructor
file_name must be in the format of “file_pathfile_name.feature”.
- #update_score ⇒ Object
Methods inherited from RuleTarget
Constructor Details
#initialize(file_name) ⇒ Feature
file_name must be in the format of “file_pathfile_name.feature”
31 32 33 34 35 36 37 38 |
# File 'lib/cuke_sniffer/feature.rb', line 31 def initialize(file_name) super(file_name) @scenarios = [] @scenarios_score = 0 @total_score = 0 @feature_lines = IO.readlines(file_name) split_feature(file_name, feature_lines) unless @feature_lines == [] end |
Instance Attribute Details
#background ⇒ Object
Scenario: The background of a Feature, created as a Scenario object
16 17 18 |
# File 'lib/cuke_sniffer/feature.rb', line 16 def background @background end |
#feature_lines ⇒ Object
String array: A list of all the lines in a feature file
28 29 30 |
# File 'lib/cuke_sniffer/feature.rb', line 28 def feature_lines @feature_lines end |
#scenarios ⇒ Object
Scenario array: A list of all scenarios contained in a feature file
19 20 21 |
# File 'lib/cuke_sniffer/feature.rb', line 19 def scenarios @scenarios end |
#scenarios_score ⇒ Object
int: Total score from all of the scenarios contained in the feature
22 23 24 |
# File 'lib/cuke_sniffer/feature.rb', line 22 def scenarios_score @scenarios_score end |
#total_score ⇒ Object
int: Total score of the feature and its scenarios
25 26 27 |
# File 'lib/cuke_sniffer/feature.rb', line 25 def total_score @total_score end |
Instance Method Details
#==(comparison_object) ⇒ Object
:nodoc:
40 41 42 43 |
# File 'lib/cuke_sniffer/feature.rb', line 40 def ==(comparison_object) # :nodoc: super(comparison_object) && comparison_object.scenarios == scenarios end |
#update_score ⇒ Object
45 46 47 48 49 |
# File 'lib/cuke_sniffer/feature.rb', line 45 def update_score @scenarios_score += @background.score unless @background.nil? @scenarios.each { |scenario| @scenarios_score += scenario.score } @total_score = @scenarios_score + @score end |