Class: Nukumber::Model::FeatureElement

Inherits:
Object
  • Object
show all
Defined in:
lib/nukumber/model/feature_element.rb

Direct Known Subclasses

Background, Scenario, ScenarioOutline

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, line, description, feature) ⇒ FeatureElement

Returns a new instance of FeatureElement.



10
11
12
13
14
15
16
17
18
# File 'lib/nukumber/model/feature_element.rb', line 10

def initialize(name, line, description, feature)
  if name.length == 0
    raise "Feature elements must be named (#{feature.file_path}:#{line})"
  elsif name[0, 1] !~ /[a-zA-Z]/
    raise "Feature element names must begin with a letter (#{feature.file_path}:#{line})"
  end
  @name, @line, @description, @feature = name, line, description, feature
  @steps = []
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



6
7
8
# File 'lib/nukumber/model/feature_element.rb', line 6

def description
  @description
end

#featureObject (readonly)

Returns the value of attribute feature.



7
8
9
# File 'lib/nukumber/model/feature_element.rb', line 7

def feature
  @feature
end

#lineObject (readonly)

Returns the value of attribute line.



6
7
8
# File 'lib/nukumber/model/feature_element.rb', line 6

def line
  @line
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/nukumber/model/feature_element.rb', line 6

def name
  @name
end

#stepsObject

Returns the value of attribute steps.



8
9
10
# File 'lib/nukumber/model/feature_element.rb', line 8

def steps
  @steps
end

Instance Method Details

#longsymObject



24
25
26
# File 'lib/nukumber/model/feature_element.rb', line 24

def longsym
  (@feature.name.nukesym.to_s + LONGSYM_DELIM + name.nukesym.to_s).to_sym
end

#shortsymObject



20
21
22
# File 'lib/nukumber/model/feature_element.rb', line 20

def shortsym
  name.nukesym
end

#step_argsObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/nukumber/model/feature_element.rb', line 32

def step_args
  step_args = []
  @steps.each do |s|
    step_args << s.args.all_row_hashes unless s.args.empty?
  end
  while step_args.is_a? Array and step_args.size == 1
    step_args = step_args.first
  end
  step_args
end

#to_sObject



28
29
30
# File 'lib/nukumber/model/feature_element.rb', line 28

def to_s
  "#{keyword} \"#{name}\""
end