Class: CukeSniffer::Feature

Inherits:
FeatureRuleTarget show all
Defined in:
lib/cuke_sniffer/feature.rb

Overview

Author

Robert Cochran ([email protected])

Copyright

Copyright © 2014 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

Attributes inherited from FeatureRuleTarget

#name, #tags

Attributes inherited from RuleTarget

#location, #rules_hash, #score, #type

Instance Method Summary collapse

Methods inherited from FeatureRuleTarget

#is_comment_and_tag?

Methods inherited from RuleTarget

#good?, #is_comment?, #problem_percentage, #store_rule, #store_rule_many_times

Constructor Details

#initialize(file_name) ⇒ Feature

file_name must be in the format of “file_pathfile_name.feature”



35
36
37
38
39
40
41
42
43
# File 'lib/cuke_sniffer/feature.rb', line 35

def initialize(file_name)
  super(file_name)
  @type = "Feature"
  @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

#backgroundObject

Scenario: The background of a Feature, created as a Scenario object



20
21
22
# File 'lib/cuke_sniffer/feature.rb', line 20

def background
  @background
end

#feature_linesObject

String array: A list of all the lines in a feature file



32
33
34
# File 'lib/cuke_sniffer/feature.rb', line 32

def feature_lines
  @feature_lines
end

#scenariosObject

Scenario array: A list of all scenarios contained in a feature file



23
24
25
# File 'lib/cuke_sniffer/feature.rb', line 23

def scenarios
  @scenarios
end

#scenarios_scoreObject

int: Total score from all of the scenarios contained in the feature



26
27
28
# File 'lib/cuke_sniffer/feature.rb', line 26

def scenarios_score
  @scenarios_score
end

#total_scoreObject

int: Total score of the feature and its scenarios



29
30
31
# File 'lib/cuke_sniffer/feature.rb', line 29

def total_score
  @total_score
end

Instance Method Details

#==(comparison_object) ⇒ Object

:nodoc:



45
46
47
48
# File 'lib/cuke_sniffer/feature.rb', line 45

def ==(comparison_object) # :nodoc:
  super(comparison_object) &&
      comparison_object.scenarios == scenarios
end

#update_scoreObject



50
51
52
53
54
# File 'lib/cuke_sniffer/feature.rb', line 50

def update_score
  @scenarios_score += @background.score unless @background.nil?
  @scenarios.each { |scenario| @scenarios_score += scenario.score }
  @total_score = @scenarios_score + @score
end