Sha256: 73473b8c7e950ebd9373d573b336c9f1c463b5edca06dc175fedc1fdd64d90ee

Contents?: true

Size: 1.39 KB

Versions: 22

Compression:

Stored size: 1.39 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'
require 'cucumber/ast'
require 'cucumber/rb_support/rb_language'

module Cucumber
  module Ast
    describe Background do

      before do
        extend(RbSupport::RbDsl)
        @step_mother = StepMother.new
        @step_mother.load_natural_language('en')
        @rb = @step_mother.load_programming_language('rb')

        $x = $y = nil
        Before do
          $x = 2
        end
        Given /y is (\d+)/ do |n|
          $y = $x * n.to_i
        end

        register

        @visitor = Visitor.new(@step_mother)
        @visitor.options = {}

        @feature = mock('feature', :visit? => true).as_null_object
      end

      def register
        @step_mother.register_step_definitions(@rb.step_definitions)
      end

      it "should execute Before blocks before background steps" do
        background = Background.new(
          comment=Comment.new(''),
          line=2,
          keyword="", 
          name="",
          steps=[
            Step.new(7, "Given", "y is 5")
          ])

        scenario = Scenario.new(
          background,
          comment=Comment.new(""), 
          tags=Tags.new(98,[]),
          line=99,
          keyword="", 
          name="", 
          steps=[])
        background.feature = @feature
        @visitor.visit_background(background)
        $x.should == 2
        $y.should == 10
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 5 rubygems

Version Path
aslakhellesoy-cucumber-0.3.100 spec/cucumber/ast/background_spec.rb
aslakhellesoy-cucumber-0.3.101.2 spec/cucumber/ast/background_spec.rb
aslakhellesoy-cucumber-0.3.101 spec/cucumber/ast/background_spec.rb
aslakhellesoy-cucumber-0.3.102.1 spec/cucumber/ast/background_spec.rb
aslakhellesoy-cucumber-0.3.102.2 spec/cucumber/ast/background_spec.rb
aslakhellesoy-cucumber-0.3.102 spec/cucumber/ast/background_spec.rb
aslakhellesoy-cucumber-0.3.97 spec/cucumber/ast/background_spec.rb
aslakhellesoy-cucumber-0.3.98 spec/cucumber/ast/background_spec.rb
aslakhellesoy-cucumber-0.3.99 spec/cucumber/ast/background_spec.rb
dwaite-cucumber-0.3.101 spec/cucumber/ast/background_spec.rb
engineyard-cucumber-0.3.101 spec/cucumber/ast/background_spec.rb
kosmas58-cucumber-0.3.100 spec/cucumber/ast/background_spec.rb
kosmas58-cucumber-0.3.102 spec/cucumber/ast/background_spec.rb
kosmas58-cucumber-0.3.97 spec/cucumber/ast/background_spec.rb
kosmas58-cucumber-0.3.98 spec/cucumber/ast/background_spec.rb
kosmas58-cucumber-0.3.99 spec/cucumber/ast/background_spec.rb
cucumber-0.3.102 spec/cucumber/ast/background_spec.rb
cucumber-0.3.101 spec/cucumber/ast/background_spec.rb
cucumber-0.3.100 spec/cucumber/ast/background_spec.rb
cucumber-0.3.99 spec/cucumber/ast/background_spec.rb