Sha256: db9ab7432f44af2a63c579f9b9d0066134d1f2624f9f592f1448c8f7502a4dc7
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
module CucumberAnalytics class ParsedFeature < FeatureElement attr_reader :tags attr_accessor :background attr_accessor :tests # Creates a new ParsedFeature object and, if *source_lines* is provided, # populates the object. def initialize(source_lines = nil) super @tags = [] @tests = [] parse_feature(source_lines) if source_lines end # Returns true if the feature contains a background, false otherwise. def has_background? !@background.nil? end # Returns the scenarios contained in the feature. def scenarios @tests.select { |test| test.is_a? ParsedScenario } end # Returns the outlines contained in the feature. def outlines @tests.select { |test| test.is_a? ParsedScenarioOutline } end # Returns the number scenarios contained in the feature. def scenario_count scenarios.count end # Returns the number outlines contained in the feature. def outline_count outlines.count end # Returns the number of tests contained in the feature. def test_count @tests.count end # Returns the number of test cases contained in the feature. def test_case_count scenario_count + outlines.reduce(0) { |sum, outline| sum += outline.examples.count } end def contains [@background] + @tests end private def parse_feature(source_lines) parse_feature_element_tags(source_lines) parse_feature_element(source_lines) end def parse_feature_element_description(source_lines) until source_lines.first =~ /^\s*(?:(?:Scenario: )|(?:Scenario Outline: )|(?:Background: )|(?:@ ))/ or source_lines.empty? @description << source_lines.first.strip source_lines.shift end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cucumber_analytics-0.0.2 | lib/cucumber_analytics/parsed_feature.rb |