Class: Cucumber::Ast::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/ast/feature.rb

Overview

Represents the root node of a parsed feature.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(comment, tags, name, feature_elements) ⇒ Feature

Returns a new instance of Feature.



8
9
10
11
12
# File 'lib/cucumber/ast/feature.rb', line 8

def initialize(comment, tags, name, feature_elements)
  @comment, @tags, @name, @feature_elements = comment, tags, name, feature_elements
  feature_elements.each{|feature_element| feature_element.feature = self}
  @lines = []
end

Instance Attribute Details

#features=(value) ⇒ Object (writeonly)

Sets the attribute features

Parameters:

  • value

    the value to set the attribute features to.



6
7
8
# File 'lib/cucumber/ast/feature.rb', line 6

def features=(value)
  @features = value
end

#fileObject

Returns the value of attribute file.



5
6
7
# File 'lib/cucumber/ast/feature.rb', line 5

def file
  @file
end

#lines=(value) ⇒ Object (writeonly)

Sets the attribute lines

Parameters:

  • value

    the value to set the attribute lines to.



6
7
8
# File 'lib/cucumber/ast/feature.rb', line 6

def lines=(value)
  @lines = value
end

Instance Method Details

#accept(visitor) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/cucumber/ast/feature.rb', line 23

def accept(visitor)
  visitor.current_feature_lines = @lines
  visitor.visit_comment(@comment)
  visitor.visit_tags(@tags)
  visitor.visit_feature_name(@name)
  @feature_elements.each do |feature_element|
    visitor.visit_feature_element(feature_element) if @features.visit?(feature_element, @lines)
  end
end

#backtrace_line(step_name, line) ⇒ Object



41
42
43
# File 'lib/cucumber/ast/feature.rb', line 41

def backtrace_line(step_name, line)
  "#{file_line(line)}:in `#{step_name}'"
end

#file_line(line) ⇒ Object



45
46
47
# File 'lib/cucumber/ast/feature.rb', line 45

def file_line(line)
  "#{@file}:#{line}"
end

#matches_scenario_names?(scenario_names) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/cucumber/ast/feature.rb', line 19

def matches_scenario_names?(scenario_names)
  @feature_elements.detect{|e| e.matches_scenario_names?(scenario_names)}
end

#scenario_executed(scenario) ⇒ Object



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

def scenario_executed(scenario)
  @features.scenario_executed(scenario) if @features
end

#step_executed(step) ⇒ Object



37
38
39
# File 'lib/cucumber/ast/feature.rb', line 37

def step_executed(step)
  @features.step_executed(step) if @features
end

#tagged_with?(tag_names, check_elements = true) ⇒ Boolean

Returns:

  • (Boolean)


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

def tagged_with?(tag_names, check_elements=true)
  @tags.among?(tag_names) || 
  (check_elements && @feature_elements.detect{|e| e.tagged_with?(tag_names)})
end

#to_sexpObject



49
50
51
52
53
54
55
56
57
# File 'lib/cucumber/ast/feature.rb', line 49

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