Class: Cucumber::Ast::Features

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filter) ⇒ Features

Returns a new instance of Features.



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

def initialize(filter)
  @filter = filter

  @features = []
  @scenarios = []
  @steps = Hash.new{|steps, status| steps[status] = []}
end

Instance Attribute Details

#scenariosObject (readonly)

Returns the value of attribute scenarios.



4
5
6
# File 'lib/cucumber/ast/features.rb', line 4

def scenarios
  @scenarios
end

#stepsObject (readonly)

Returns the value of attribute steps.



4
5
6
# File 'lib/cucumber/ast/features.rb', line 4

def steps
  @steps
end

Instance Method Details

#accept(visitor) ⇒ Object



32
33
34
35
36
# File 'lib/cucumber/ast/features.rb', line 32

def accept(visitor)
  @features.each do |feature|
    visitor.visit_feature(feature) if visit?(feature, [])
  end
end

#add_feature(feature) ⇒ Object



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

def add_feature(feature)
  feature.features = self
  @features << feature
end

#scenario_executed(scenario) ⇒ Object



24
25
26
# File 'lib/cucumber/ast/features.rb', line 24

def scenario_executed(scenario)
  @scenarios << scenario
end

#step_executed(step) ⇒ Object



28
29
30
# File 'lib/cucumber/ast/features.rb', line 28

def step_executed(step)
  @steps[step.status] << step
end

#visit?(node, lines) ⇒ Boolean

Returns:

  • (Boolean)


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

def visit?(node, lines)
  @filter.matched?(node) &&
  (lines.empty? ? true : node.at_lines?(lines))
end