Sha256: c919198eab6e802466c70fa035e95de5f060046826ad4c946ae5d83adcf9e780

Contents?: true

Size: 1000 Bytes

Versions: 1

Compression:

Stored size: 1000 Bytes

Contents

module Courgette
  
  class Feature
    
    attr_reader :path
    
    def initialize(path)
      @path = path
    end
    
    def name
      name_lines.first.split(':', 2).second.strip
    end
    
    def feature_elements_size
      ast.instance_variable_get('@feature_elements').size
    end
    
    def to_param
      relative_path.sub(/^\//, '').sub(/\.feature$/, '').parameterize.dasherize.to_s
    end
    
    def to_html
      step_mother = Object.new
      step_mother.extend(Cucumber::StepMother)
      visitor = Cucumber::Formatter::Html.new(step_mother, nil, {})
      visitor.visit_feature(ast)
    end
    
  private
  
    def relative_path
      File.expand_path(path).sub(Courgette.feature_root, '')
    end
  
    def name_lines
      ast.name.respond_to?(:lines) ? ast.name.lines.to_a : ast.name.to_a
    end

    def feature_file
      @feature_file ||= Cucumber::FeatureFile.new(path)
    end
  
    def ast
      @ast ||= feature_file.parse
    end
    
    
  end
  
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jnicklas-courgette-0.0.2 lib/courgette/feature.rb