Sha256: bec502a645f1eafed7ae85ea760a3236ebfaf94e6bebf9aa3dc0268837179fd1
Contents?: true
Size: 1.99 KB
Versions: 9
Compression:
Stored size: 1.99 KB
Contents
require 'spec_helper' require 'minimart/web/cookbooks' describe Minimart::Web::Cookbooks do let(:inventory_directory) { 'spec/fixtures/' } let(:data_path) { File.join(directory, 'data.json') } subject do Minimart::Web::Cookbooks.new(inventory_directory: inventory_directory) end describe '::new' do it 'should set the #inventory_directory' do expect(subject.inventory_directory).to eq inventory_directory end it 'should build a data structure with the proper cookbooks' do expect(subject.keys).to include 'sample_cookbook' end it 'should load the cookbooks provided' do expect(subject['sample_cookbook'].first).to be_a Minimart::Cookbook end context 'when there are multiple versions of the same cookbook' do let(:cookbook_one) do c = Minimart::Cookbook.new(nil) allow(c).to receive(:name).and_return 'test-book' allow(c).to receive(:version).and_return '1.9.0' c end let(:cookbook_two) do c = Minimart::Cookbook.new(nil) allow(c).to receive(:name).and_return 'test-book' allow(c).to receive(:version).and_return '1.19.0' c end let(:cookbooks) { [cookbook_one, cookbook_two] } before(:each) do allow_any_instance_of(Minimart::Web::Cookbooks).to receive(:cookbooks).and_return cookbooks end it 'should load both cookbooks' do expect(subject['test-book'].size).to eq 2 end it 'should properly sort them in version descending order' do expect(subject['test-book'][0].version).to eq '1.19.0' expect(subject['test-book'][1].version).to eq '1.9.0' end end end describe '::to_json' do let(:result) { JSON.parse(subject.to_json) } it 'should return the proper data structure as JSON' do expect(result.first['name']).to eq 'sample_cookbook' end it 'should include the number of versions available' do expect(result.first['available_versions']).to eq 1 end end end
Version data entries
9 entries across 9 versions & 1 rubygems