Sha256: 05eaac6b13c745713b4807a028c41315b9d29985205cfdd0e1f9ff9da0313ba9

Contents?: true

Size: 1.97 KB

Versions: 9

Compression:

Stored size: 1.97 KB

Contents

#
# Copyright:: Copyright (c) 2014 Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'spec_helper'
require 'chef-dk/policyfile/community_cookbook_source'

describe ChefDK::Policyfile::CommunityCookbookSource do

  let(:cookbook_source) { ChefDK::Policyfile::CommunityCookbookSource.new }

  let(:default_community_uri) { "https://supermarket.chef.io" }

  let(:http_connection) { double("Chef::HTTP::Simple") }

  let(:universe_response_encoded) { IO.read(File.join(fixtures_path, "cookbooks_api/small_universe.json")) }

  let(:pruned_universe) { JSON.parse(IO.read(File.join(fixtures_path, "cookbooks_api/pruned_small_universe.json"))) }

  before do
    expect(Chef::HTTP::Simple).to receive(:new).with(default_community_uri).and_return(http_connection)
    expect(http_connection).to receive(:get).with("/universe").and_return(universe_response_encoded)
  end

  it "fetches the universe graph" do
    actual_universe = cookbook_source.universe_graph
    expect(actual_universe).to have_key("apt")
    expect(actual_universe["apt"]).to eq(pruned_universe["apt"])
    expect(cookbook_source.universe_graph).to eq(pruned_universe)
  end

  it "generates location options for a cookbook from the given graph" do
    expected_opts = { artifactserver: "https://supermarket.chef.io/api/v1/cookbooks/apache2/versions/1.10.4/download", version: "1.10.4" }
    expect(cookbook_source.source_options_for("apache2", "1.10.4")).to eq(expected_opts)
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
chef-dk-0.8.0 spec/unit/policyfile/community_cookbook_source_spec.rb
chef-dk-0.7.0 spec/unit/policyfile/community_cookbook_source_spec.rb
chef-dk-0.6.2 spec/unit/policyfile/community_cookbook_source_spec.rb
chef-dk-0.6.1 spec/unit/policyfile/community_cookbook_source_spec.rb
chef-dk-0.6.0 spec/unit/policyfile/community_cookbook_source_spec.rb
chef-dk-0.5.1 spec/unit/policyfile/community_cookbook_source_spec.rb
chef-dk-0.5.0 spec/unit/policyfile/community_cookbook_source_spec.rb
chef-dk-0.5.0.rc.1 spec/unit/policyfile/community_cookbook_source_spec.rb
chef-dk-0.4.0 spec/unit/policyfile/community_cookbook_source_spec.rb