Sha256: 7737e84238a4861cd2ba9e8c9a78f32a44069e9b7419f8448f81e56145618d77

Contents?: true

Size: 1.35 KB

Versions: 24

Compression:

Stored size: 1.35 KB

Contents

require 'kontena/stacks_cache'
require 'yaml'

describe Kontena::Cli::Stacks::YAML::RegistryLoader do
  include FixturesHelpers

  before do
    allow(File).to receive(:exist?).and_return(false)
  end

  describe '#match' do
    it 'returns false when input is not a registry path' do
      expect(described_class.match?('foofoo')).to be_falsey
    end

    it 'returns true when file exists' do
      expect(described_class.match?('user/stack')).to be_truthy
      expect(described_class.match?('user/stack:1.0.0')).to be_truthy
    end
  end

  describe 'instance methods' do
    let(:subject) { described_class.new('user/stack') }

    before do
      allow(Kontena::StacksCache).to receive(:pull).with('user/stack').and_return(
        fixture('kontena_v3.yml')
      )
    end

    describe '#read_content' do
      it 'reads the file' do
        allow(Kontena::Cli::Config).to receive(:current_account).and_return(double(stacks_url: 'foo'))
        expect(subject.read_content).to match /^stack:/
      end
    end

    describe '#origin' do
      it 'returns "uri"' do
        expect(subject.origin).to eq 'registry'
      end
    end

    describe '#registry' do
      it 'returns "file://"' do
        allow(Kontena::Cli::Config).to receive(:current_account).and_return(double(stacks_url: 'foo'))
        expect(subject.registry).to eq 'foo'
      end
    end
  end
end


Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
kontena-cli-1.5.0.pre5 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.5.0.pre4 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.5.0.pre3 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.5.0.pre2 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.5.0.pre1 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.3 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.3.rc1 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.2 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.2.rc1 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.2.pre1 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.1 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.1.rc1 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.1.pre1 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.0 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.0.rc2 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.0.rc1 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.0.pre14 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.0.pre13 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.0.pre12 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb
kontena-cli-1.4.0.pre11 spec/kontena/cli/stacks/yaml/stack_file_loader/registry_loader_spec.rb