Skip to content

Commit

Permalink
substitute doc string in scenario outline
Browse files Browse the repository at this point in the history
  • Loading branch information
hanachin committed Jul 9, 2014
1 parent fc055e4 commit a66318f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
13 changes: 13 additions & 0 deletions examples/scenario_outline_multiline_string_substitution.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Feature: using scenario outlines
Scenario Outline: a simple outline
Given there is a monster called <name>
Then the monster introduced himself:
"""
Ahhhhhhh! i'm <name>!
"""

Examples:
| name |
| John |
| "John Smith" |
| "O'Flannahan" |
4 changes: 4 additions & 0 deletions examples/steps/steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
@monster_name.should == ""
end

step "the monster introduced himself:" do |self_introduction|
self_introduction.should include @monster_name
end

step "there is a monster with :count hitpoints" do |count|
@monster = count
end
Expand Down
10 changes: 8 additions & 2 deletions lib/turnip/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,14 @@ def to_scenarios(examples)
scenario.steps = steps.map do |step|
new_description = substitute(step.description, headers, row)
new_extra_args = step.extra_args.map do |ea|
next ea unless ea.instance_of?(Turnip::Table)
Turnip::Table.new(ea.map {|t_row| t_row.map {|t_col| substitute(t_col, headers, row) } })
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
Expand Down
2 changes: 1 addition & 1 deletion spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
end

it "prints out failures and successes" do
@result.should include('35 examples, 3 failures, 5 pending')
@result.should include('38 examples, 3 failures, 5 pending')
end

it "includes features in backtraces" do
Expand Down

0 comments on commit a66318f

Please sign in to comment.