Class: Cucumber::Core::Ast::Feature

Inherits:
Object
  • Object
show all
Includes:
DescribesItself, HasLocation, Names
Defined in:
lib/cucumber/core/ast/feature.rb

Overview

Represents the root node of a parsed feature.

Instance Attribute Summary collapse

Attributes included from Names

#name

Instance Method Summary collapse

Methods included from DescribesItself

#describe_to

Methods included from HasLocation

#all_locations, #attributes, #file, #file_colon_line, #line, #multiline_arg

Methods included from Names

#inspect, #legacy_conflated_name_and_description, #to_s

Constructor Details

#initialize(language, location, background, comments, tags, keyword, name, description, scenario_definitions) ⇒ Feature

Returns a new instance of Feature.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cucumber/core/ast/feature.rb', line 19

def initialize(language, location, background, comments, tags, keyword, name, description, scenario_definitions)
  @language = language
  @location = location
  @background = background
  @comments = comments
  @tags = tags
  @keyword = keyword
  @name = name
  @description = description
  @feature_elements = scenario_definitions
end

Instance Attribute Details

#backgroundObject (readonly)

Returns the value of attribute background.



15
16
17
# File 'lib/cucumber/core/ast/feature.rb', line 15

def background
  @background
end

#commentsObject (readonly)

Returns the value of attribute comments.



15
16
17
# File 'lib/cucumber/core/ast/feature.rb', line 15

def comments
  @comments
end

#descriptionObject (readonly)

Returns the value of attribute description.



15
16
17
# File 'lib/cucumber/core/ast/feature.rb', line 15

def description
  @description
end

#feature_elementsObject (readonly)

Returns the value of attribute feature_elements.



15
16
17
# File 'lib/cucumber/core/ast/feature.rb', line 15

def feature_elements
  @feature_elements
end

#keywordObject (readonly)

Returns the value of attribute keyword.



15
16
17
# File 'lib/cucumber/core/ast/feature.rb', line 15

def keyword
  @keyword
end

#languageObject (readonly)

Returns the value of attribute language.



15
16
17
# File 'lib/cucumber/core/ast/feature.rb', line 15

def language
  @language
end

#locationObject (readonly)

Returns the value of attribute location.



15
16
17
# File 'lib/cucumber/core/ast/feature.rb', line 15

def location
  @location
end

#tagsObject (readonly)

Returns the value of attribute tags.



15
16
17
# File 'lib/cucumber/core/ast/feature.rb', line 15

def tags
  @tags
end

Instance Method Details

#childrenObject



31
32
33
# File 'lib/cucumber/core/ast/feature.rb', line 31

def children
  [background] + @feature_elements
end

#short_nameObject



35
36
37
38
39
40
41
42
# File 'lib/cucumber/core/ast/feature.rb', line 35

def short_name
  first_line = name.split(/\n/)[0]
  if first_line =~ /#{language.feature_keywords}:(.*)/
    $1.strip
  else
    first_line
  end
end

#to_sexpObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/cucumber/core/ast/feature.rb', line 44

def to_sexp
  sexp = [:feature, file, name]
  comment = @comment.to_sexp
  sexp += [comment] if comment
  tags = @tags.to_sexp
  sexp += tags if tags.any?
  sexp += [@background.to_sexp] if @background
  sexp += @feature_elements.map{|fe| fe.to_sexp}
  sexp
end