Sha256: da7a5339864a456d594399472301cef4c0ff113dc4a8d73a82e9ca3b80faeae4

Contents?: true

Size: 1.63 KB

Versions: 21

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

module Berkshelf
  describe Source do
    describe "#universe"
    describe "#cookbook"
    describe "#versions"

    describe "#==" do
      it "is the same if the uri matches" do
        first = described_class.new("http://localhost:8080")
        other = described_class.new("http://localhost:8080")

        expect(first).to eq(other)
      end

      it "is not the same if the uri is different" do
        first = described_class.new("http://localhost:8089")
        other = described_class.new("http://localhost:8080")

        expect(first).to_not eq(other)
      end
    end

    describe '.default?' do
      it 'returns true when the source is the default' do
        instance = described_class.new(Berksfile::DEFAULT_API_URL)
        expect(instance).to be_default
      end

      it 'returns true when the scheme is different' do
        instance = described_class.new('http://supermarket.chef.io')
        expect(instance).to be_default
      end

      it 'returns false when the source is not the default' do
        instance = described_class.new('http://localhost:8080')
        expect(instance).to_not be_default
      end
    end

    describe "#search" do
      let (:cookbooks) {[ 
        APIClient::RemoteCookbook.new("cb1","1.0.8"),
        APIClient::RemoteCookbook.new("cb1","1.0.22")
      ]}

      before do
        allow_any_instance_of(APIClient::Connection).to receive(:universe).and_return(cookbooks)
      end

      it "returns the latest version" do
        instance = described_class.new(Berksfile::DEFAULT_API_URL)
        expect(instance.search("cb1")).to eq [cookbooks[1]]
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
berkshelf-5.5.0 spec/unit/berkshelf/source_spec.rb
berkshelf-5.4.0 spec/unit/berkshelf/source_spec.rb
berkshelf-5.3.0 spec/unit/berkshelf/source_spec.rb
berkshelf-5.2.0 spec/unit/berkshelf/source_spec.rb
berkshelf-5.1.0 spec/unit/berkshelf/source_spec.rb
berkshelf-5.0.0 spec/unit/berkshelf/source_spec.rb
berkshelf-4.3.5 spec/unit/berkshelf/source_spec.rb
berkshelf-4.3.3 spec/unit/berkshelf/source_spec.rb
berkshelf-4.3.2 spec/unit/berkshelf/source_spec.rb
berkshelf-4.3.1 spec/unit/berkshelf/source_spec.rb
berkshelf-4.3.0 spec/unit/berkshelf/source_spec.rb
berkshelf-4.2.3 spec/unit/berkshelf/source_spec.rb
berkshelf-4.2.2 spec/unit/berkshelf/source_spec.rb
berkshelf-4.2.1 spec/unit/berkshelf/source_spec.rb
berkshelf-4.2.0 spec/unit/berkshelf/source_spec.rb
berkshelf-4.1.1 spec/unit/berkshelf/source_spec.rb
berkshelf-4.1.0 spec/unit/berkshelf/source_spec.rb
berkshelf-4.0.1 spec/unit/berkshelf/source_spec.rb
berkshelf-4.0.0 spec/unit/berkshelf/source_spec.rb
berkshelf-3.3.0 spec/unit/berkshelf/source_spec.rb