Sha256: 6dfc12e644df571762f4886eb2bf25922b5ce6242ed27daf690afe43dc39dd12

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'

describe 'git' do
  before do
    mock_config do
      use_recipe :git
      set :deploy_to, '/foo/bar'
    end
  end

  it 'has branch' do
    config.branch.should == 'master'
  end

  context 'with repository' do
    before do
      mock_config { set :repository, 'git@example.com/test-app.git' }
    end

    it 'sets application from repo' do
      config.application.should == 'test-app'
    end

    describe 'deploy:setup' do
      it 'clones repository' do
        cli_execute 'deploy:setup'
        config.should have_run('mkdir -p `dirname /foo/bar` && git clone --no-checkout git@example.com/test-app.git /foo/bar')
      end

      it 'invokes update during setup' do
        config.namespaces[:deploy].should_receive(:update)
        cli_execute 'deploy:setup'
      end
    end

    describe 'deploy:update' do
      it 'updates' do
        cli_execute 'deploy:update'
        config.should have_run('cd /foo/bar && git fetch origin && git reset --hard origin/master')
      end

      it 'updates submodules' do
        mock_config { set :enable_submodules, true }
        cli_execute 'deploy:update'
        config.should have_run('cd /foo/bar && git fetch origin && git reset --hard origin/master && git submodule init && git submodule -q sync && git submodule -q update')
      end
    end
  end

  it 'has current revision' do
    config.should_receive(:capture).with('cd /foo/bar && git rev-parse HEAD') { "baz\n" }
    config.current_revision.should == 'baz'
  end

  it 'shows pending' do
    config.should_receive(:current_revision) { 'baz' }
    config.namespaces[:deploy].should_receive(:system).with('git log --pretty=medium --stat baz..origin/master')
    cli_execute 'deploy:pending'
  end

  it 'sets forward agent' do
    config.ssh_options[:forward_agent].should == true
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capistrano-deploy-0.3.1 spec/git_spec.rb
capistrano-deploy-0.3.0 spec/git_spec.rb