Class: CucumberAnalytics::Feature
- Inherits:
-
FeatureElement
- Object
- FeatureElement
- CucumberAnalytics::Feature
- Includes:
- Containing, Taggable
- Defined in:
- lib/cucumber_analytics/feature.rb
Overview
A class modeling a Cucumber Feature.
Instance Attribute Summary collapse
-
#background ⇒ Object
The Background object contained by the Feature.
-
#tests ⇒ Object
The TestElement objects contained by the Feature.
Attributes included from Taggable
Attributes inherited from FeatureElement
#description, #description_text, #name
Attributes included from Nested
Attributes included from Raw
Attributes included from Sourceable
Instance Method Summary collapse
-
#contains ⇒ Object
Returns the immediate child elements of the feature (i.e. its Background, Scenario, and Outline objects..
-
#has_background? ⇒ Boolean
Returns true if the feature contains a background, false otherwise.
-
#initialize(source = nil) ⇒ Feature
constructor
Creates a new Feature object and, if source is provided, populates the object.
-
#outline_count ⇒ Object
Returns the number of outlines contained in the feature.
-
#outlines ⇒ Object
Returns the outlines contained in the feature.
-
#scenario_count ⇒ Object
Returns the number of scenarios contained in the feature.
-
#scenarios ⇒ Object
Returns the scenarios contained in the feature.
-
#test_case_count ⇒ Object
Returns the number of test cases contained in the feature.
-
#test_count ⇒ Object
Returns the number of tests contained in the feature.
-
#to_s ⇒ Object
Returns gherkin representation of the feature.
Methods included from Taggable
#all_tag_elements, #all_tags, #applied_tag_elements, #applied_tags
Methods included from Nested
Constructor Details
#initialize(source = nil) ⇒ Feature
Creates a new Feature object and, if source is provided, populates the object.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cucumber_analytics/feature.rb', line 20 def initialize(source = nil) parsed_feature = process_source(source) super(parsed_feature) @tags = [] @tag_elements = [] @tests = [] build_feature(parsed_feature) if parsed_feature end |
Instance Attribute Details
#background ⇒ Object
The Background object contained by the Feature
12 13 14 |
# File 'lib/cucumber_analytics/feature.rb', line 12 def background @background end |
#tests ⇒ Object
The TestElement objects contained by the Feature
15 16 17 |
# File 'lib/cucumber_analytics/feature.rb', line 15 def tests @tests end |
Instance Method Details
#contains ⇒ Object
Returns the immediate child elements of the feature (i.e. its Background, Scenario, and Outline objects.
73 74 75 |
# File 'lib/cucumber_analytics/feature.rb', line 73 def contains @background ? [@background] + @tests : @tests end |
#has_background? ⇒ Boolean
Returns true if the feature contains a background, false otherwise.
33 34 35 |
# File 'lib/cucumber_analytics/feature.rb', line 33 def has_background? !@background.nil? end |
#outline_count ⇒ Object
Returns the number of outlines contained in the feature.
53 54 55 |
# File 'lib/cucumber_analytics/feature.rb', line 53 def outline_count outlines.count end |
#outlines ⇒ Object
Returns the outlines contained in the feature.
43 44 45 |
# File 'lib/cucumber_analytics/feature.rb', line 43 def outlines @tests.select { |test| test.is_a? Outline } end |
#scenario_count ⇒ Object
Returns the number of scenarios contained in the feature.
48 49 50 |
# File 'lib/cucumber_analytics/feature.rb', line 48 def scenario_count scenarios.count end |
#scenarios ⇒ Object
Returns the scenarios contained in the feature.
38 39 40 |
# File 'lib/cucumber_analytics/feature.rb', line 38 def scenarios @tests.select { |test| test.is_a? Scenario } end |
#test_case_count ⇒ Object
Returns the number of test cases contained in the feature.
63 64 65 66 67 68 69 |
# File 'lib/cucumber_analytics/feature.rb', line 63 def test_case_count scenario_count + outlines.reduce(0) { |outline_sum, outline| outline_sum += outline.examples.reduce(0) { |example_sum, example| example_sum += example.rows.count } } end |
#test_count ⇒ Object
Returns the number of tests contained in the feature.
58 59 60 |
# File 'lib/cucumber_analytics/feature.rb', line 58 def test_count @tests.count end |
#to_s ⇒ Object
Returns gherkin representation of the feature.
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/cucumber_analytics/feature.rb', line 79 def to_s text = '' text << tag_output_string + "\n" unless .empty? text << "Feature:#{name_output_string}" text << "\n" + description_output_string unless description_text.empty? text << "\n\n" + background_output_string if background text << "\n\n" + tests_output_string unless tests.empty? text end |