From a66318f9104a96b93915857a82800969ca34a47b Mon Sep 17 00:00:00 2001 From: Seiei Higa Date: Thu, 17 Apr 2014 11:23:40 +0900 Subject: [PATCH] substitute doc string in scenario outline --- ...io_outline_multiline_string_substitution.feature | 13 +++++++++++++ examples/steps/steps.rb | 4 ++++ lib/turnip/builder.rb | 10 ++++++++-- spec/integration_spec.rb | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 examples/scenario_outline_multiline_string_substitution.feature diff --git a/examples/scenario_outline_multiline_string_substitution.feature b/examples/scenario_outline_multiline_string_substitution.feature new file mode 100644 index 0000000..b2020b8 --- /dev/null +++ b/examples/scenario_outline_multiline_string_substitution.feature @@ -0,0 +1,13 @@ +Feature: using scenario outlines + Scenario Outline: a simple outline + Given there is a monster called + Then the monster introduced himself: + """ + Ahhhhhhh! i'm ! + """ + + Examples: + | name | + | John | + | "John Smith" | + | "O'Flannahan" | diff --git a/examples/steps/steps.rb b/examples/steps/steps.rb index d9fab64..7e4df1d 100644 --- a/examples/steps/steps.rb +++ b/examples/steps/steps.rb @@ -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 diff --git a/lib/turnip/builder.rb b/lib/turnip/builder.rb index 4b76c82..7871795 100644 --- a/lib/turnip/builder.rb +++ b/lib/turnip/builder.rb @@ -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 diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index 1bf82b3..29f14b2 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -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