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

#description

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

#name, #to_s

Constructor Details

#initializeFeature

Returns a new instance of Feature.



20
21
22
23
# File 'lib/cucumber/core/ast/feature.rb', line 20

def initialize(*)
  super
  feature_elements.each { |e| e.feature = self }
end

Instance Attribute Details

#backgroundObject (readonly)

Returns the value of attribute background.



17
18
19
# File 'lib/cucumber/core/ast/feature.rb', line 17

def background
  @background
end

#commentsObject (readonly)

Returns the value of attribute comments.



17
18
19
# File 'lib/cucumber/core/ast/feature.rb', line 17

def comments
  @comments
end

#feature_elementsObject (readonly)

Returns the value of attribute feature_elements.



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

def feature_elements
  @feature_elements
end

#keywordObject (readonly)

Returns the value of attribute keyword.



17
18
19
# File 'lib/cucumber/core/ast/feature.rb', line 17

def keyword
  @keyword
end

#languageObject

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.



17
18
19
# File 'lib/cucumber/core/ast/feature.rb', line 17

def location
  @location
end

#tagsObject (readonly)

Returns the value of attribute tags.



17
18
19
# File 'lib/cucumber/core/ast/feature.rb', line 17

def tags
  @tags
end

#titleObject (readonly)

Returns the value of attribute title.



17
18
19
# File 'lib/cucumber/core/ast/feature.rb', line 17

def title
  @title
end

Instance Method Details

#childrenObject



29
30
31
# File 'lib/cucumber/core/ast/feature.rb', line 29

def children
  [background] + @feature_elements
end

#gherkin_statement(statement = nil) ⇒ Object



25
26
27
# File 'lib/cucumber/core/ast/feature.rb', line 25

def gherkin_statement(statement=nil)
  @gherkin_statement ||= statement
end

#short_nameObject



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

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

#to_sexpObject



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

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