Class: Cucumber::Tree::Feature
- Inherits:
-
Object
- Object
- Cucumber::Tree::Feature
- Defined in:
- lib/cucumber/tree/feature.rb
Constant Summary collapse
- MIN_PADDING =
2
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #add_row_scenario(template_scenario, values, line) ⇒ Object
- #add_scenario(name, line, &proc) ⇒ Object
-
#initialize(header, &proc) ⇒ Feature
constructor
A new instance of Feature.
- #padding_length ⇒ Object
- #Scenario(name, &proc) ⇒ Object
- #scenario_named(name) ⇒ Object
- #Table(matrix = [], &proc) ⇒ Object
Constructor Details
#initialize(header, &proc) ⇒ Feature
Returns a new instance of Feature.
9 10 11 12 13 |
# File 'lib/cucumber/tree/feature.rb', line 9 def initialize(header, &proc) @header = header @scenarios = [] instance_eval(&proc) if block_given? end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
7 8 9 |
# File 'lib/cucumber/tree/feature.rb', line 7 def file @file end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
4 5 6 |
# File 'lib/cucumber/tree/feature.rb', line 4 def header @header end |
Instance Method Details
#accept(visitor) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cucumber/tree/feature.rb', line 48 def accept(visitor) visitor.visit_header(@header) @scenarios.each do |scenario| if scenario.row? visitor.visit_row_scenario(scenario) else visitor.visit_regular_scenario(scenario) end end end |
#add_row_scenario(template_scenario, values, line) ⇒ Object
21 22 23 24 25 |
# File 'lib/cucumber/tree/feature.rb', line 21 def add_row_scenario(template_scenario, values, line) scenario = RowScenario.new(self, template_scenario, values, line) @scenarios << scenario scenario end |
#add_scenario(name, line, &proc) ⇒ Object
15 16 17 18 19 |
# File 'lib/cucumber/tree/feature.rb', line 15 def add_scenario(name, line, &proc) scenario = Scenario.new(self, name, line, &proc) @scenarios << scenario scenario end |
#padding_length ⇒ Object
31 32 33 |
# File 'lib/cucumber/tree/feature.rb', line 31 def padding_length MIN_PADDING end |
#Scenario(name, &proc) ⇒ Object
35 36 37 |
# File 'lib/cucumber/tree/feature.rb', line 35 def Scenario(name, &proc) add_scenario(name, &proc) end |
#scenario_named(name) ⇒ Object
27 28 29 |
# File 'lib/cucumber/tree/feature.rb', line 27 def scenario_named(name) @scenarios.find {|s| s.name == name} end |
#Table(matrix = [], &proc) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/cucumber/tree/feature.rb', line 39 def Table(matrix = [], &proc) table = Table.new(matrix) proc.call(table) template_scenario = @scenarios.last matrix[1..-1].each do |row| add_row_scenario(template_scenario, row, row.line) end end |