<commit_before>require File.dirname(__FILE__) + '/../../spec_helper'
require 'cucumber/step_mom'
require 'cucumber/ast'
require 'cucumber/core_ext/string'

module Cucumber
  module Ast
    describe ScenarioOutline do
      it "should execute outline steps when row matches 1 step" do
        step_mother = mock("StepMother")

        scenario_outline = ScenarioOutline.new(
          Comment.new(""),
          Tags.new([]),
          "My outline",
          [
            Step.new(step_mother, 'Given', 'a <color> <veggie>')
          ],
          [
            %w{green cucumber},
            %w{red tomato}
          ]
        )
        
        step_mother.should_receive(:execute_step_by_name).with("a green cucumber", anything)
        step_mother.should_receive(:execute_step_by_name).with("a red tomato", anything)
        visitor = Visitor.new
        scenario_outline.accept(visitor)

        # Just keeping this code for debugging (output)
        #
        # require 'cucumber/formatter/pretty'
        # mom = Object.new
        # mom.extend(StepMom)
        # visitor = Formatter::Pretty.new(mom, STDOUT)
        # visitor.visit_feature_element(scenario_outline)
      end

      it "should execute outline steps when row matches 2 steps" do
        step_mother = mock("StepMother")

        scenario_outline = ScenarioOutline.new(
          Comment.new(""),
          Tags.new([]),
          "My outline",
          [
            Step.new(step_mother, 'Given', 'a <color> glove'),
            Step.new(step_mother, 'Given', 'a tasty <veggie>')
          ],
          [
            %w{green cucumber},
            %w{red tomato}
          ]
        )

        step_mother.should_receive(:execute_step_by_name).with("a green glove", anything)
        step_mother.should_receive(:execute_step_by_name).with("a tasty cucumber", anything)
        step_mother.should_receive(:execute_step_by_name).with("a red glove", anything)
        step_mother.should_receive(:execute_step_by_name).with("a tasty tomato", anything)
        visitor = Visitor.new
        scenario_outline.accept(visitor)
      end
    end
  end
end<commit_msg>Updated spec to reflect current 0.1.13 behaviour<commit_after>require File.dirname(__FILE__) + '/../../spec_helper'
require 'cucumber/step_mom'
require 'cucumber/ast'
require 'cucumber/core_ext/string'

module Cucumber
  module Ast
    describe ScenarioOutline do
      # Scenario Outline: reusing place holder
      #   Given there are <start> cucumbers
      #   When I eat <eat> cucumbers
      #   Then I should have <left> cucumbers
      #   And I should have <eat> cucumbers in my belly
      # 
      # Examples:
      #   | start  | eat  | left |
      #   |  12    |  5   |  7   |
      #   |  20    |  6   |  14  |
      it "should reuse variables" do
        step_mother = mock("StepMother")

        scenario_outline = ScenarioOutline.new(
          Comment.new(""),
          Tags.new([]),
          "My outline",
          [
            Step.new(step_mother, 'Given', 'there are <start> cucumbers'),
            Step.new(step_mother, 'When',  'I eat <eat> cucumbers'),
            Step.new(step_mother, 'Then',  'I should have <left> cucumbers'),
            Step.new(step_mother, 'And',   'I should have <eat> cucumbers in my belly')
          ],
          [
            %w{start eat left},
            %w{12 5 7},
            %w{20 6 14}
          ]
        )

        step_mother.should_receive(:execute_step_by_name).with("there are 12 cucumbers", anything)
        step_mother.should_receive(:execute_step_by_name).with("I eat 5 cucumbers", anything)
        step_mother.should_receive(:execute_step_by_name).with("I should have 7 cucumbers", anything)
        step_mother.should_receive(:execute_step_by_name).with("I should have 5 cucumbers in my belly", anything)

        step_mother.should_receive(:execute_step_by_name).with("there are 20 cucumbers", anything)
        step_mother.should_receive(:execute_step_by_name).with("I eat 6 cucumbers", anything)
        step_mother.should_receive(:execute_step_by_name).with("I should have 14 cucumbers", anything)
        step_mother.should_receive(:execute_step_by_name).with("I should have 6 cucumbers in my belly", anything)

        if ENV['CUCUMBER_DEBUG']
          require 'cucumber/formatter/pretty'
          mom = Object.new
          mom.extend(StepMom)
          visitor = Formatter::Pretty.new(mom, STDOUT)
          visitor.visit_feature_element(scenario_outline)
        else
          visitor = Visitor.new
          visitor.visit_feature_element(scenario_outline)
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10652549697493517, 'fraction_numerical': 0.00756266205704408, 'mean_word_length': 2.3519188993482985, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '516330', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1389, 'n_words': 310}