Sha256: 6929dd85864eaba4d43594b3092f3cde01d2c43090f434525aa2856e00fb8185

Contents?: true

Size: 1.7 KB

Versions: 16

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'

describe 'multistage' do
  before do
    mock_config do
      use_recipes :multistage

      set :default_stage, :development
      stage(:development, :branch => 'develop') { set :foo, 'bar' }
      stage(:production,  :branch => 'master')  { set :foo, 'baz' }
      stage :another_stage, :foo => 'bar'

      task(:example) {}
    end
  end

  it 'uses default stage' do
    cli_execute 'example'
    config.current_stage.should == 'development'
    config.foo.should == 'bar'
  end

  it 'aborts when no stage selected' do
    with_stderr do |output|
      config.unset :default_stage
      expect { cli_execute 'example' }.to raise_error(SystemExit)
      output.should include('No stage specified. Please specify one of: development, production')
    end
  end

  it 'uses specified stage' do
    cli_execute %w[production example]
    config.current_stage.should == 'production'
    config.foo.should == 'baz'
  end

  it 'sets variables from options' do
    cli_execute 'another_stage'
    config.foo.should == 'bar'
  end

  it 'accepts default option' do
    mock_config { stage :to_be_default, :default => true }
    config.default_stage.should == :to_be_default
  end

  context 'with git' do
    before do
      mock_config { use_recipe :git }
    end

    it 'infers stage using local branch' do
      config.stub(:local_branch) { 'master' }
      cli_execute 'example'
      config.current_stage.should == 'production'
      config.branch.should == 'master'
    end

    it 'uses default state when local branch not matches' do
      config.stub(:local_branch) { 'foo' }
      cli_execute 'example'
      config.current_stage.should == 'development'
      config.branch.should == 'develop'
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
capistrano_recipes-1.4.2 spec/multistage_spec.rb
capistrano_recipes-1.4.1 spec/multistage_spec.rb
capistrano_recipes-1.4.0 spec/multistage_spec.rb
capistrano_recipes-1.3.4 spec/multistage_spec.rb
capistrano_recipes-1.3.3 spec/multistage_spec.rb
capistrano_recipes-1.3.2 spec/multistage_spec.rb
capistrano_recipes-1.3.1 spec/multistage_spec.rb
capistrano_recipes-1.3.0 spec/multistage_spec.rb
capistrano_recipes-1.2.0 spec/multistage_spec.rb
capistrano_recipes-1.1.0 spec/multistage_spec.rb
capistrano_recipes-1.0.5 spec/multistage_spec.rb
capistrano_recipes-1.0.4 spec/multistage_spec.rb
capistrano_recipes-1.0.3 spec/multistage_spec.rb
capistrano_recipes-1.0.2 spec/multistage_spec.rb
capistrano_recipes-1.0.1 spec/multistage_spec.rb
capistrano_recipes-1.0.0 spec/multistage_spec.rb