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.
-
#scenarios ⇒ Object
readonly
Returns the value of attribute scenarios.
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.
10 11 12 13 14 |
# File 'lib/cucumber/tree/feature.rb', line 10 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.
8 9 10 |
# File 'lib/cucumber/tree/feature.rb', line 8 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 |
#scenarios ⇒ Object (readonly)
Returns the value of attribute scenarios.
5 6 7 |
# File 'lib/cucumber/tree/feature.rb', line 5 def scenarios @scenarios end |
Instance Method Details
#accept(visitor) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/cucumber/tree/feature.rb', line 51 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
22 23 24 25 26 |
# File 'lib/cucumber/tree/feature.rb', line 22 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
16 17 18 19 20 |
# File 'lib/cucumber/tree/feature.rb', line 16 def add_scenario(name, line, &proc) scenario = Scenario.new(self, name, line, &proc) @scenarios << scenario scenario end |
#padding_length ⇒ Object
32 33 34 |
# File 'lib/cucumber/tree/feature.rb', line 32 def padding_length MIN_PADDING end |
#Scenario(name, &proc) ⇒ Object
36 37 38 39 |
# File 'lib/cucumber/tree/feature.rb', line 36 def Scenario(name, &proc) line = caller[0] =~ /:(\d+)$/ ? $1 : nil add_scenario(name, line, &proc) end |
#scenario_named(name) ⇒ Object
28 29 30 |
# File 'lib/cucumber/tree/feature.rb', line 28 def scenario_named(name) @scenarios.find {|s| s.name == name} end |
#Table(matrix = [], &proc) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/cucumber/tree/feature.rb', line 41 def Table(matrix = [], &proc) table = Table.new(matrix) proc.call(table) template_scenario = @scenarios.last template_scenario.table_header = matrix[0] matrix[1..-1].each do |row| add_row_scenario(template_scenario, row, row.line) end end |