Sha256: 329c8b861327c0552cf960188225755591fd9df8e74d8cfad20df281cbd21295

Contents?: true

Size: 1.62 KB

Versions: 5

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

describe Aptible::CLI::Helpers::App::GitRemoteHandleStrategy do
  let!(:work_dir) { Dir.mktmpdir }
  after { FileUtils.remove_entry work_dir }
  around { |example| Dir.chdir(work_dir) { example.run } }

  context 'with git repo' do
    before { `git init` }

    context 'with aptible remote' do
      before do
        `git remote add aptible git@beta.aptible.com:some-env/some-app.git`
        `git remote add prod git@beta.aptible.com:prod-env/prod-app.git`
      end

      it 'defaults to the Aptible remote' do
        s = described_class.new({})
        expect(s.app_handle).to eq('some-app')
        expect(s.env_handle).to eq('some-env')
        expect(s.usable?).to be_truthy
      end

      it 'allows explicitly passing a remote' do
        s = described_class.new(remote: 'prod')
        expect(s.app_handle).to eq('prod-app')
        expect(s.env_handle).to eq('prod-env')
        expect(s.usable?).to be_truthy
      end

      it 'accepts a remote from the environment' do
        ClimateControl.modify APTIBLE_REMOTE: 'prod' do
          s = described_class.new(remote: 'prod')
          expect(s.app_handle).to eq('prod-app')
        end
      end

      it 'is not usable when the remote does not exist' do
        s = described_class.new(remote: 'foobar')
        expect(s.usable?).to be_falsey
      end

      it 'outputs the remote when explaining' do
        s = described_class.new(remote: 'prod')
        expect(s.explain).to match(/derived from git remote prod/)
      end
    end
  end

  it 'is not usable outside of a git repo' do
    s = described_class.new({})
    expect(s.usable?).to be_falsey
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
aptible-cli-0.7.4 spec/aptible/cli/helpers/git_remote_handle_strategy_spec.rb
aptible-cli-0.7.3 spec/aptible/cli/helpers/git_remote_handle_strategy_spec.rb
aptible-cli-0.7.2 spec/aptible/cli/helpers/git_remote_handle_strategy_spec.rb
aptible-cli-0.7.1 spec/aptible/cli/helpers/git_remote_handle_strategy_spec.rb
aptible-cli-0.7.0 spec/aptible/cli/helpers/git_remote_handle_strategy_spec.rb