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

Instance Method Summary collapse

Methods included from DescribesItself

#describe_to

Methods included from HasLocation

#attributes, #file, #file_colon_line, #line, #match_locations?, #multiline_arg

Methods included from Names

#inspect, #legacy_conflated_name_and_description, #name, #to_s

Constructor Details

#initialize(gherkin_statement, language, location, background, comments, tags, keyword, title, description, feature_elements) ⇒ Feature

Returns a new instance of Feature.



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

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

Instance Attribute Details

#backgroundObject (readonly)

Returns the value of attribute background.



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

def background
  @background
end

#commentsObject (readonly)

Returns the value of attribute comments.



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

def comments
  @comments
end

#feature_elementsObject (readonly)

Returns the value of attribute feature_elements.



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

def feature_elements
  @feature_elements
end

#gherkin_statementObject (readonly)

Returns the value of attribute gherkin_statement.



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

def gherkin_statement
  @gherkin_statement
end

#keywordObject (readonly)

Returns the value of attribute keyword.



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

def keyword
  @keyword
end

#languageObject (readonly)

Returns the value of attribute language.



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

def language
  @language
end

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#tagsObject (readonly)

Returns the value of attribute tags.



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

def tags
  @tags
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#childrenObject



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

def children
  [background] + @feature_elements
end

#short_nameObject



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

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

#to_sexpObject



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

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