class CukeModeler::FeatureFile

A class modeling a feature file in a Cucumber suite.

Attributes

comments[RW]

The comment models contained by the modeled feature file

feature[RW]

The feature model contained by the modeled feature file

path[RW]

The file path of the modeled feature file

Public Class Methods

new(file_path = nil) click to toggle source

Creates a new FeatureFile object and, if file_path is provided, populates the object.

Calls superclass method
# File lib/cuke_modeler/models/feature_file.rb, line 21
def initialize(file_path = nil)
  @path = file_path
  @comments = []

  super(file_path)

  return unless file_path
  raise(ArgumentError, "Unknown file: #{file_path.inspect}") unless File.exist?(file_path)

  processed_feature_file_data = process_feature_file(file_path)
  populate_featurefile(self, processed_feature_file_data)
end

Public Instance Methods

children() click to toggle source

Returns the model objects that belong to this model.

# File lib/cuke_modeler/models/feature_file.rb, line 40
def children
  @feature ? [@feature] : []
end
name() click to toggle source

Returns the name of the modeled feature file.

# File lib/cuke_modeler/models/feature_file.rb, line 35
def name
  File.basename(@path.gsub('\\', '/')) if @path
end
to_s() click to toggle source

Returns a string representation of this model. For a feature file model, this will be the path of the modeled feature file.

# File lib/cuke_modeler/models/feature_file.rb, line 46
def to_s
  path.to_s
end

Private Instance Methods

process_feature_file(file_path) click to toggle source
# File lib/cuke_modeler/models/feature_file.rb, line 54
def process_feature_file(file_path)
  source_text = IO.read(file_path)

  feature_file_data = Parsing.parse_text(source_text, file_path)
  feature_file_data = feature_file_data.merge({ 'path' => file_path })

  feature_file_data
end