Class: Cucumber::Tree::Feature
- Defined in:
- lib/gems/cucumber-0.1.15/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_row_scenario_outline(template_scenario, values, line) ⇒ Object
- #add_scenario(name, line, &proc) ⇒ Object
- #add_scenario_outline(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
- #ScenarioOutline(name, &proc) ⇒ Object
- #Table(matrix = [], &proc) ⇒ Object
Constructor Details
#initialize(header, &proc) ⇒ Feature
Returns a new instance of Feature.
10 11 12 13 14 |
# File 'lib/gems/cucumber-0.1.15/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/gems/cucumber-0.1.15/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/gems/cucumber-0.1.15/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/gems/cucumber-0.1.15/lib/cucumber/tree/feature.rb', line 5 def scenarios @scenarios end |
Instance Method Details
#accept(visitor) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/feature.rb', line 74 def accept(visitor) visitor.visit_header(@header) @scenarios.each do |scenario| if scenario.outline? && !scenario.row? visitor.visit_scenario_outline(scenario) elsif scenario.row? visitor.visit_row_scenario(scenario) else visitor.visit_regular_scenario(scenario) end end end |
#add_row_scenario(template_scenario, values, line) ⇒ Object
28 29 30 31 32 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/feature.rb', line 28 def add_row_scenario(template_scenario, values, line) scenario = RowScenario.new(self, template_scenario, values, line) @scenarios << scenario scenario end |
#add_row_scenario_outline(template_scenario, values, line) ⇒ Object
34 35 36 37 38 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/feature.rb', line 34 def add_row_scenario_outline(template_scenario, values, line) scenario = RowScenarioOutline.new(self, template_scenario, values, line) @scenarios << scenario scenario end |
#add_scenario(name, line, &proc) ⇒ Object
16 17 18 19 20 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/feature.rb', line 16 def add_scenario(name, line, &proc) scenario = Scenario.new(self, name, line, &proc) @scenarios << scenario scenario end |
#add_scenario_outline(name, line, &proc) ⇒ Object
22 23 24 25 26 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/feature.rb', line 22 def add_scenario_outline(name, line, &proc) scenario = ScenarioOutline.new(self, name, line, &proc) @scenarios << scenario scenario end |
#padding_length ⇒ Object
44 45 46 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/feature.rb', line 44 def padding_length MIN_PADDING end |
#Scenario(name, &proc) ⇒ Object
48 49 50 51 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/feature.rb', line 48 def Scenario(name, &proc) line = caller[0] =~ /:(\d+)$/ ? $1 : nil add_scenario(name, line, &proc) end |
#scenario_named(name) ⇒ Object
40 41 42 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/feature.rb', line 40 def scenario_named(name) @scenarios.find {|s| s.name == name} end |
#ScenarioOutline(name, &proc) ⇒ Object
53 54 55 56 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/feature.rb', line 53 def ScenarioOutline(name, &proc) line = caller[0] =~ /:(\d+)$/ ? $1 : nil add_scenario_outline(name, line, &proc) end |
#Table(matrix = [], &proc) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/feature.rb', line 58 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| if template_scenario.outline? add_row_scenario_outline(template_scenario, row, row.line) else add_row_scenario(template_scenario, row, row.line) end end end |