Class: Turnip::Builder::ScenarioOutline
- Inherits:
-
Object
- Object
- Turnip::Builder::ScenarioOutline
- Defined in:
- lib/turnip/builder.rb
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
-
#initialize(raw) ⇒ ScenarioOutline
constructor
A new instance of ScenarioOutline.
- #to_scenarios(examples) ⇒ Object
Methods included from Name
Methods included from Tags
#metadata_hash, #tags, #tags_hash
Constructor Details
#initialize(raw) ⇒ ScenarioOutline
Returns a new instance of ScenarioOutline.
77 78 79 80 |
# File 'lib/turnip/builder.rb', line 77 def initialize(raw) @raw = raw @steps = [] end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
75 76 77 |
# File 'lib/turnip/builder.rb', line 75 def steps @steps end |
Instance Method Details
#to_scenarios(examples) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/turnip/builder.rb', line 82 def to_scenarios(examples) rows = examples.rows.map(&:cells) headers = rows.shift rows.map do |row| Scenario.new(@raw).tap do |scenario| scenario.steps = steps.map do |step| new_description = substitute(step.description, headers, row) new_extra_args = step.extra_args.map do |ea| case ea when String substitute(ea, headers, row) when Turnip::Table Turnip::Table.new(ea.map {|t_row| t_row.map {|t_col| substitute(t_col, headers, row) } }) else ea end end Step.new(new_description, new_extra_args, step.line, step.keyword) end end end end |