Sha256: d736892cdbf885d33b02a988189c016b33ca4e133329141c81536d17bfe36854

Contents?: true

Size: 1.37 KB

Versions: 9

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

describe Minimart::Mirror::Sources do

  describe '::new' do
    let(:source_1) { 'https://supermarket.getchef.com' }
    let(:source_2) { 'https://supermarket.internal.com' }

    subject do
      Minimart::Mirror::Sources.new([source_1, source_2])
    end

    it 'should build a source with the first url provided' do
      expect(subject.map &:base_url ).to include source_1
    end

    it 'should build a source with the second url provided' do
      expect(subject.map &:base_url ).to include source_2
    end
  end

  describe '#find_cookbook' do
    subject do
      Minimart::Mirror::Sources.new(['https://supermarket.internal.com'])
    end

    let(:cookbook) { double('cookbook', name: 'mysql', version: '1.0.0') }

    before(:each) do
      allow_any_instance_of(Minimart::Mirror::Source).to receive(:cookbooks).and_return [cookbook]
    end

    context 'when a source has the given cookbook' do
      it 'should return the cookbook' do
        expect(subject.find_cookbook('mysql', '1.0.0')).to eq cookbook
      end
    end

    context 'when the cookbook cannot be found' do
      it 'should raise the proper exception' do
        expect {
          subject.find_cookbook('mysql', '2.0.0')
        }.to raise_error(
          Minimart::Error::CookbookNotFound,
          "The cookbook mysql with the version 2.0.0 could not be found")
      end
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
minimart-1.2.5 spec/lib/minimart/mirror/sources_spec.rb
minimart-1.2.4 spec/lib/minimart/mirror/sources_spec.rb
minimart-1.2.3 spec/lib/minimart/mirror/sources_spec.rb
minimart-1.2.0 spec/lib/minimart/mirror/sources_spec.rb
minimart-1.1.6 spec/lib/minimart/mirror/sources_spec.rb
minimart-1.1.3 spec/lib/minimart/mirror/sources_spec.rb
minimart-1.0.2 spec/lib/minimart/mirror/sources_spec.rb
minimart-1.0.1 spec/lib/minimart/mirror/sources_spec.rb
minimart-0.0.1 spec/lib/minimart/mirror/sources_spec.rb