Sha256: c8f582ae4d6f840a15810d56380e484cd14a5f0edf8354178fd8f9203a0a1c5d

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

module Capistrano

  class DummyDSL
    include DSL
  end

  # see also - spec/integration/dsl_spec.rb
  describe DSL do
    let(:dsl) { DummyDSL.new }

    describe '#t' do
      before do
        I18n.expects(:t).with(:phrase, {count: 2, scope: :capistrano})
      end

      it 'delegates to I18n' do
        dsl.t(:phrase, count: 2)
      end
    end

    describe '#stages' do
      before do
        Dir.expects(:[]).with('config/deploy/*.rb').
          returns(['config/deploy/staging.rb', 'config/deploy/production.rb'])
      end

      it 'returns a list of defined stages' do
        expect(dsl.stages).to eq %w{staging production}
      end
    end

    describe '#stage_set?' do
      subject { dsl.stage_set? }

      context 'stage is set' do
        before do
          dsl.set(:stage, :sandbox)
        end
        it { should be_true }
      end

      context 'stage is not set' do
        before do
          dsl.set(:stage, nil)
        end
        it { should be_false }
      end
    end

    describe '#sudo' do

      before do
        dsl.expects(:execute).with(:sudo, :my, :command)
      end

      it 'prepends sudo, delegates to execute' do
        dsl.sudo(:my, :command)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capistrano-3.0.1 spec/lib/capistrano/dsl_spec.rb
capistrano-3.0.0 spec/lib/capistrano/dsl_spec.rb
capistrano-3.0.0.pre14 spec/lib/capistrano/dsl_spec.rb