Sha256: 0a00cafe7302211c3c67728d77d6b0f68997330281dba2c4c46f85443a0907da

Contents?: true

Size: 1.84 KB

Versions: 15

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'

describe Turnip::DSL do
  let(:context) { double.tap { |s| s.extend(Turnip::DSL) }}
  let(:an_object) { Object.new.tap { |o| o.extend(Turnip::Execute) }}
  describe '.steps_for' do
    before do
      ::RSpec.stub(:configure)
    end

    it 'creates a new module and adds steps to it' do
      mod = context.steps_for(:foo) do
        step("foo") { "foo" }
      end
      an_object.extend mod
      an_object.step("foo").should == "foo"
    end

    it 'remembers the name of the module' do
      mod = context.steps_for(:foo) {}
      mod.tag.should == :foo
    end

    it 'tells RSpec to include the module' do
      config = double
      RSpec.should_receive(:configure).and_yield(config)
      config.should_receive(:include)

      context.steps_for(:foo) {}
    end

    it 'warns of deprecation when called with :global' do
      context.should_receive(:warn)
      mod = context.steps_for(:global) do
        step("foo") { "foo" }
      end
      an_object.extend Turnip::Steps
      an_object.step("foo").should == "foo"
    end
  end

  describe '.step' do
    it 'adds steps to Turnip::Steps' do
      context.step('this is a test') { "foo" }
      context.step('this is another test') { "bar" }
      an_object.extend Turnip::Steps
      an_object.step("this is a test").should == "foo"
    end
  end

  describe '.placeholder' do
    before { Turnip::Placeholder.send(:placeholders).clear }

    it 'registers the placeholder globally' do
      context.placeholder('example') { true }
      Turnip::Placeholder.send(:placeholders).should have_key('example')
    end

    it 'registers the multi placeholder globally' do
      context.placeholder('example_1', 'example_2') { true }
      Turnip::Placeholder.send(:placeholders).should have_key('example_1')
      Turnip::Placeholder.send(:placeholders).should have_key('example_2')
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
turnip-3.0.0 spec/dsl_spec.rb
turnip-3.0.0.pre.beta.5 spec/dsl_spec.rb
turnip-3.0.0.pre.beta.4 spec/dsl_spec.rb
turnip-3.0.0.pre.beta.3 spec/dsl_spec.rb
turnip-3.0.0.pre.beta.2 spec/dsl_spec.rb
turnip-3.0.0.pre.beta.1 spec/dsl_spec.rb
turnip-2.1.1 spec/dsl_spec.rb
turnip-2.1.0 spec/dsl_spec.rb
turnip-2.0.2 spec/dsl_spec.rb
turnip-2.0.1 spec/dsl_spec.rb
turnip-2.0.0 spec/dsl_spec.rb
turnip-1.3.1 spec/dsl_spec.rb
turnip-1.3.0 spec/dsl_spec.rb
turnip-1.2.4 spec/dsl_spec.rb
turnip-1.2.3 spec/dsl_spec.rb