Sha256: 348ef57ec9ad0f4d7902356e4bbb0002712006071d828c3c38f7844d2ddbced1

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'

describe HeadChef::Cookbook do
  let(:cookbook_resource) { double('Ridley::CookbookResouce') }
  let(:cached_cookbooks) { [] }
  let(:cached_cookbook) { double('Berkshelf::CachedCookbook') }

  subject { HeadChef::Cookbook.new('test', '0.0.1', '0.0.2') }

  describe 'ClassMethods' do
    describe '::new' do
      it 'reads name' do
        expect(subject.name).to eq('test')
      end

      it 'reads berkshelf version' do
        expect(subject.berkshelf_version).to eq('0.0.1')
      end

      it 'reads chef version' do
        expect(subject.chef_version).to eq('0.0.2')
      end
    end
  end

  describe 'InstanceMethods' do
    describe '#diff' do
      before(:each) do
        HeadChef.stub_chain(:chef_server, :cookbook).
          and_return(cookbook_resource)

        allow(cookbook_resource).to receive(:find).
          with(subject.name, subject.berkshelf_version).
          and_return(cookbook_resource)
        allow(cookbook_resource).to receive(:manifest).and_return(Hashie::Mash.new)

        HeadChef.stub_chain(:berksfile, :cached_cookbooks).
          and_return(cached_cookbooks)
        allow(cached_cookbooks).to receive(:find).and_return(cached_cookbook)

        allow(cached_cookbook).to receive(:path)
        allow(subject).to receive(:remove_ignored_files).and_return([])
      end

      after(:each) do
        subject.diff
      end

      it 'retrieves cookbook checksums from chef server' do
        expect(cookbook_resource).to receive(:find).
          with(subject.name, subject.berkshelf_version)
      end

      it 'loads cookbook from berkshelf cache' do
        expect(cached_cookbooks).to receive(:find)
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
head_chef-0.1.1 spec/cookbook_spec.rb
head_chef-0.1.0 spec/cookbook_spec.rb