Sha256: 047584dd878532d3f9da439a156bb022b8b653e4bdad56c4f81cefad12d6f35e

Contents?: true

Size: 1.51 KB

Versions: 5

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

describe Berkshelf::API::CacheBuilder::Worker::Opscode do
  describe "ClassMethods" do
    subject { described_class }
    its(:worker_type) { should eql("opscode") }
  end

  let(:cookbooks) { ["chicken", "tuna"] }
  let(:chicken_versions) { ["1.0", "2.0"] }
  let(:tuna_versions) { ["3.0.0", "3.0.1"] }
  let(:connection) do
    connection = double('connection')
    connection.stub(:cookbooks).and_return(cookbooks)
    connection
  end

  subject do
    Berkshelf::API::CacheManager.start
    described_class.new
  end

  describe "#cookbooks" do
    let(:location_type) { described_class.worker_type }
    let(:location_path) { Berkshelf::API::SiteConnector::Opscode::V1_API}

    it "returns an array of RemoteCookbooks described by the server" do
      expected_value = [
        Berkshelf::API::RemoteCookbook.new("chicken", "1.0", location_type, location_path),
        Berkshelf::API::RemoteCookbook.new("chicken", "2.0", location_type, location_path),
        Berkshelf::API::RemoteCookbook.new("tuna", "3.0.0", location_type, location_path),
        Berkshelf::API::RemoteCookbook.new("tuna", "3.0.1", location_type, location_path)
      ]

      connection.should_receive(:future).with(:versions, "chicken").and_return(double(value: chicken_versions))
      connection.should_receive(:future).with(:versions, "tuna").and_return(double(value: tuna_versions))
      subject.should_receive(:connection).at_least(1).times.and_return(connection)
      expect(subject.cookbooks).to eql(expected_value)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
berkshelf-api-1.1.1 spec/unit/berkshelf/api/cache_builder/worker/opscode_spec.rb
berkshelf-api-1.1.0 spec/unit/berkshelf/api/cache_builder/worker/opscode_spec.rb
berkshelf-api-1.0.0 spec/unit/berkshelf/api/cache_builder/worker/opscode_spec.rb
berkshelf-api-0.2.0 spec/unit/berkshelf/api/cache_builder/worker/opscode_spec.rb
berkshelf-api-0.1.0 spec/unit/berkshelf/api/cache_builder/worker/opscode_spec.rb