Sha256: 8cb3b243cc442f761e65873c59f6322bcf1af244e40513484d799371825b4dd7

Contents?: true

Size: 1.68 KB

Versions: 69

Compression:

Stored size: 1.68 KB

Contents

require 'spec_helper'

describe Dockly::Docker::Registry do
  subject { described_class.new(:name => :dockly_registry) }

  describe '#authenticate!' do
    context 'when authentication is not required' do
      before { subject.authentication_required false }

      it 'does nothing' do
        ::Docker.should_not_receive(:authenticate!)
        subject.authenticate!
      end
    end

    context 'when the password has not been supplied via the DSL' do
      subject {
        described_class.new(
          :name => 'no-password',
          :email => 'fake@email.com',
          :username => 'fakeuser'
        )
      }

      before { ::Docker.stub(:authenticate!) }

      it 'prompts the user for the password' do
        ENV.should_receive(:[]).and_return('password')
        expect { subject.authenticate! }.to_not raise_error
      end
    end

    context 'when the password has been supplied via the DSL' do
      subject {
        described_class.new(
          :name => 'no-password',
          :email => 'fake@email.com',
          :password => 'fakepassword',
          :username => 'fakeuser'
        )
      }

      context 'when authentication succeeds' do
        before { ::Docker.stub(:authenticate!) }

        it 'does nothing' do
          ENV.should_not_receive(:[])
          expect { subject.authenticate! }.to_not raise_error
        end
      end

      context 'when authentication fails' do
        before do
          ::Docker.stub(:authenticate!).and_raise(::Docker::Error::AuthenticationError)
        end

        it 'raieses an error' do
          ENV.should_not_receive(:[])
          expect { subject.authenticate! }.to raise_error
        end
      end
    end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
dockly-4.4.1 spec/dockly/docker/registry_spec.rb
dockly-4.4.0 spec/dockly/docker/registry_spec.rb
dockly-4.3.0 spec/dockly/docker/registry_spec.rb
dockly-4.2.0 spec/dockly/docker/registry_spec.rb
dockly-4.1.0 spec/dockly/docker/registry_spec.rb
dockly-4.0.0 spec/dockly/docker/registry_spec.rb
dockly-3.4.1 spec/dockly/docker/registry_spec.rb
dockly-3.4.0 spec/dockly/docker/registry_spec.rb
dockly-3.3.0 spec/dockly/docker/registry_spec.rb
dockly-3.2.0.pre.1 spec/dockly/docker/registry_spec.rb
dockly-3.1.1 spec/dockly/docker/registry_spec.rb
dockly-3.1.0 spec/dockly/docker/registry_spec.rb
dockly-3.0.5 spec/dockly/docker/registry_spec.rb
dockly-3.0.4 spec/dockly/docker/registry_spec.rb
dockly-3.0.3 spec/dockly/docker/registry_spec.rb
dockly-3.0.2 spec/dockly/docker/registry_spec.rb
dockly-3.0.1 spec/dockly/docker/registry_spec.rb
dockly-3.0.0 spec/dockly/docker/registry_spec.rb
dockly-2.7.2 spec/dockly/docker/registry_spec.rb
dockly-2.7.1 spec/dockly/docker/registry_spec.rb