minimart 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +21 -0
- data/.rspec +3 -0
- data/.travis.yml +13 -0
- data/Gemfile +3 -0
- data/README.md +198 -0
- data/Rakefile +45 -0
- data/bin/minimart +4 -0
- data/lib/minimart.rb +15 -0
- data/lib/minimart/cli.rb +93 -0
- data/lib/minimart/commands/mirror.rb +30 -0
- data/lib/minimart/commands/web.rb +91 -0
- data/lib/minimart/configuration.rb +46 -0
- data/lib/minimart/cookbook.rb +173 -0
- data/lib/minimart/download/cookbook.rb +70 -0
- data/lib/minimart/download/git_cache.rb +60 -0
- data/lib/minimart/download/git_repository.rb +41 -0
- data/lib/minimart/error.rb +32 -0
- data/lib/minimart/inventory_requirement/base_requirement.rb +81 -0
- data/lib/minimart/inventory_requirement/git_requirement.rb +87 -0
- data/lib/minimart/inventory_requirement/git_requirements_builder.rb +101 -0
- data/lib/minimart/inventory_requirement/local_path_requirement.rb +45 -0
- data/lib/minimart/inventory_requirement/local_requirements_builder.rb +31 -0
- data/lib/minimart/inventory_requirement/supermarket_requirements_builder.rb +35 -0
- data/lib/minimart/mirror.rb +12 -0
- data/lib/minimart/mirror/dependency_graph.rb +73 -0
- data/lib/minimart/mirror/download_metadata.rb +57 -0
- data/lib/minimart/mirror/inventory_builder.rb +143 -0
- data/lib/minimart/mirror/inventory_configuration.rb +74 -0
- data/lib/minimart/mirror/inventory_requirements.rb +104 -0
- data/lib/minimart/mirror/local_store.rb +107 -0
- data/lib/minimart/mirror/source.rb +57 -0
- data/lib/minimart/mirror/source_cookbook.rb +77 -0
- data/lib/minimart/mirror/sources.rb +37 -0
- data/lib/minimart/output.rb +34 -0
- data/lib/minimart/utils/archive.rb +39 -0
- data/lib/minimart/utils/file_helper.rb +34 -0
- data/lib/minimart/utils/http.rb +60 -0
- data/lib/minimart/version.rb +3 -0
- data/lib/minimart/web.rb +10 -0
- data/lib/minimart/web/cookbook_show_page_generator.rb +78 -0
- data/lib/minimart/web/cookbooks.rb +83 -0
- data/lib/minimart/web/dashboard_generator.rb +46 -0
- data/lib/minimart/web/html_generator.rb +52 -0
- data/lib/minimart/web/markdown_parser.rb +47 -0
- data/lib/minimart/web/template_helper.rb +132 -0
- data/lib/minimart/web/universe_generator.rb +109 -0
- data/minimart.gemspec +36 -0
- data/spec/fixtures/sample_cookbook.tar.gz +0 -0
- data/spec/fixtures/sample_cookbook/Berksfile +3 -0
- data/spec/fixtures/sample_cookbook/CHANGELOG.md +3 -0
- data/spec/fixtures/sample_cookbook/Gemfile +16 -0
- data/spec/fixtures/sample_cookbook/LICENSE +3 -0
- data/spec/fixtures/sample_cookbook/README.md +42 -0
- data/spec/fixtures/sample_cookbook/Thorfile +5 -0
- data/spec/fixtures/sample_cookbook/Vagrantfile +90 -0
- data/spec/fixtures/sample_cookbook/chefignore +94 -0
- data/spec/fixtures/sample_cookbook/metadata.rb +9 -0
- data/spec/fixtures/sample_cookbook/recipes/default.rb +8 -0
- data/spec/fixtures/sample_inventory.yml +16 -0
- data/spec/fixtures/simple_git_inventory.yml +8 -0
- data/spec/fixtures/simple_inventory.yml +6 -0
- data/spec/fixtures/simple_local_path_inventory.yml +5 -0
- data/spec/fixtures/universe.json +42 -0
- data/spec/fixtures/vcr_cassettes/local_path_cookbooks.yml +3316 -0
- data/spec/fixtures/vcr_cassettes/location_specific_cookbooks.yml +3316 -0
- data/spec/fixtures/vcr_cassettes/supermarket_cookbooks_graph.yml +905 -0
- data/spec/fixtures/vcr_cassettes/supermarket_cookbooks_installing_cookbooks.yml +4218 -0
- data/spec/lib/minimart/cli_spec.rb +104 -0
- data/spec/lib/minimart/commands/mirror_spec.rb +37 -0
- data/spec/lib/minimart/commands/web_spec.rb +75 -0
- data/spec/lib/minimart/configuration_spec.rb +54 -0
- data/spec/lib/minimart/cookbook_spec.rb +137 -0
- data/spec/lib/minimart/download/cookbook_spec.rb +135 -0
- data/spec/lib/minimart/download/git_cache_spec.rb +69 -0
- data/spec/lib/minimart/download/git_repository_spec.rb +39 -0
- data/spec/lib/minimart/error_spec.rb +18 -0
- data/spec/lib/minimart/inventory_requirement/base_requirement_spec.rb +38 -0
- data/spec/lib/minimart/inventory_requirement/git_requirement_spec.rb +92 -0
- data/spec/lib/minimart/inventory_requirement/git_requirements_builder_spec.rb +130 -0
- data/spec/lib/minimart/inventory_requirement/local_path_requirement_spec.rb +35 -0
- data/spec/lib/minimart/inventory_requirement/local_requirements_builder_spec.rb +33 -0
- data/spec/lib/minimart/inventory_requirement/supermarket_requirements_builder_spec.rb +69 -0
- data/spec/lib/minimart/mirror/dependency_graph_spec.rb +123 -0
- data/spec/lib/minimart/mirror/download_metadata_spec.rb +73 -0
- data/spec/lib/minimart/mirror/inventory_builder_spec.rb +195 -0
- data/spec/lib/minimart/mirror/inventory_configuration_spec.rb +86 -0
- data/spec/lib/minimart/mirror/inventory_requirements_spec.rb +78 -0
- data/spec/lib/minimart/mirror/local_store_spec.rb +64 -0
- data/spec/lib/minimart/mirror/source_spec.rb +54 -0
- data/spec/lib/minimart/mirror/sources_spec.rb +50 -0
- data/spec/lib/minimart/output_spec.rb +29 -0
- data/spec/lib/minimart/utils/archive_spec.rb +38 -0
- data/spec/lib/minimart/utils/file_helper_spec.rb +43 -0
- data/spec/lib/minimart/utils/http_spec.rb +37 -0
- data/spec/lib/minimart/web/cookbook_show_page_generator_spec.rb +101 -0
- data/spec/lib/minimart/web/cookbooks_spec.rb +70 -0
- data/spec/lib/minimart/web/dashboard_generator_spec.rb +33 -0
- data/spec/lib/minimart/web/html_generator_spec.rb +34 -0
- data/spec/lib/minimart/web/markdown_parser_spec.rb +54 -0
- data/spec/lib/minimart/web/template_helper_spec.rb +86 -0
- data/spec/lib/minimart/web/universe_generator_spec.rb +125 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/support/file_system.rb +22 -0
- data/web/_assets/javascripts/app.js +164 -0
- data/web/_assets/javascripts/backbone.min.js +6 -0
- data/web/_assets/javascripts/jquery.min.js +4 -0
- data/web/_assets/javascripts/jquery.tabslet.min.js +9 -0
- data/web/_assets/javascripts/manifest.js +5 -0
- data/web/_assets/javascripts/underscore.min.js +5 -0
- data/web/_assets/stylesheets/font-awesome.min.css +4 -0
- data/web/_assets/stylesheets/font-mfizz.css +318 -0
- data/web/_assets/stylesheets/main.css +720 -0
- data/web/_assets/stylesheets/manifest.css +4 -0
- data/web/_assets/stylesheets/normalize.css +427 -0
- data/web/assets/fonts/FontAwesome.otf +0 -0
- data/web/assets/fonts/font-mfizz.eot +0 -0
- data/web/assets/fonts/font-mfizz.svg +1344 -0
- data/web/assets/fonts/font-mfizz.ttf +0 -0
- data/web/assets/fonts/font-mfizz.woff +0 -0
- data/web/assets/fonts/fontawesome-webfont.eot +0 -0
- data/web/assets/fonts/fontawesome-webfont.svg +520 -0
- data/web/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/web/assets/fonts/fontawesome-webfont.woff +0 -0
- data/web/assets/images/header-slim.jpg +0 -0
- data/web/assets/images/icon-search.png +0 -0
- data/web/assets/images/mad-glory-logo.png +0 -0
- data/web/assets/images/main-gradient.png +0 -0
- data/web/assets/images/top-bar-logo.png +0 -0
- data/web/assets/javascripts/application.min.js +5 -0
- data/web/assets/stylesheets/application.min.css +4 -0
- data/web/templates/cookbook_show.erb +96 -0
- data/web/templates/dashboard.erb +81 -0
- data/web/templates/layout.erb +38 -0
- metadata +433 -0
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::Mirror::InventoryConfiguration do
|
4
|
+
|
5
|
+
let(:config_file_path) { 'spec/fixtures/sample_inventory.yml' }
|
6
|
+
|
7
|
+
subject { Minimart::Mirror::InventoryConfiguration.new(config_file_path) }
|
8
|
+
|
9
|
+
describe '::new' do
|
10
|
+
context 'when the inventory config file does not exist' do
|
11
|
+
it 'should raise the proper exception' do
|
12
|
+
expect {
|
13
|
+
Minimart::Mirror::InventoryConfiguration.new('not_a_real_config.yml')
|
14
|
+
}.to raise_error(
|
15
|
+
Minimart::Error::InvalidInventoryError,
|
16
|
+
'The inventory configuration file could not be found')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'global configuration' do
|
21
|
+
let(:conf) do
|
22
|
+
{
|
23
|
+
'configuration' => {
|
24
|
+
'verify_ssl' => false,
|
25
|
+
'github' => {'github' => 'config'},
|
26
|
+
'chef' => {'chef' => 'config'}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
before(:each) do
|
32
|
+
allow(YAML).to receive(:load).and_return(conf)
|
33
|
+
end
|
34
|
+
|
35
|
+
after(:each) do
|
36
|
+
Minimart::Configuration.verify_ssl = nil
|
37
|
+
Minimart::Configuration.github_config = nil
|
38
|
+
Minimart::Configuration.chef_server_config = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should set ssl verify to the proper value' do
|
42
|
+
subject
|
43
|
+
expect(Minimart::Configuration.verify_ssl).to eq false
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should set the github config to the proper value' do
|
47
|
+
subject
|
48
|
+
expect(Minimart::Configuration.github_config).to include('github' => 'config')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should set the chef config to the proper value' do
|
52
|
+
subject
|
53
|
+
expect(Minimart::Configuration.chef_server_config).to include('chef' => 'config')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#sources' do
|
59
|
+
it 'should build sources' do
|
60
|
+
expect(subject.sources).to be_a Minimart::Mirror::Sources
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should build sources with the correct attributes' do
|
64
|
+
expect(subject.sources.map &:base_url).to include 'https://supermarket.getchef.com'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#requirements' do
|
69
|
+
it 'should build requirements' do
|
70
|
+
expect(subject.requirements).to be_a Minimart::Mirror::InventoryRequirements
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when there are no cookbooks defined in the config file' do
|
74
|
+
before(:each) do
|
75
|
+
allow_any_instance_of(File).to receive(:read).and_return "sources: \"https://supermarket.getchef.com\""
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should raise an exception' do
|
79
|
+
expect {
|
80
|
+
subject.requirements
|
81
|
+
}.to raise_error Minimart::Error::InvalidInventoryError, 'Minimart could not find any cookbooks defined in the inventory'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::Mirror::InventoryRequirements do
|
4
|
+
|
5
|
+
let(:raw_requirements) do
|
6
|
+
{
|
7
|
+
'sample_cookbook' => {'path' => 'spec/fixtures/sample_cookbook'},
|
8
|
+
'mysql' => {
|
9
|
+
'versions' => ['~> 5.6.1'],
|
10
|
+
'git' => {
|
11
|
+
'location' => 'https://github.com/opscode-cookbooks/mysql',
|
12
|
+
'branches' => ['windows'],
|
13
|
+
'refs' => ['git-ref-sha'],
|
14
|
+
'tags' => ['v5.2.0']
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
subject do
|
21
|
+
Minimart::Mirror::InventoryRequirements.new(raw_requirements)
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "::new" do
|
25
|
+
it 'should build any cookbooks for any listed versions' do
|
26
|
+
expect(subject.any? { |c| c.version_requirement == '~> 5.6.1' }).to eq true
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should build cookbooks for any git branches' do
|
30
|
+
expect(subject.any? { |c| c.respond_to?(:branch) && c.branch == 'windows' }).to eq true
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should build cookbooks for any git tags' do
|
34
|
+
expect(subject.any? { |c| c.respond_to?(:tag) && c.tag == 'v5.2.0' }).to eq true
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should build cookbooks for any git refs' do
|
38
|
+
expect(subject.any? { |c| c.respond_to?(:ref) && c.ref == 'git-ref-sha' }).to eq true
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should build any cookbooks for local paths' do
|
42
|
+
expect(subject.any? { |c| c.respond_to?(:path) && c.path == 'spec/fixtures/sample_cookbook' }).to eq true
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when no requirements can be found for a given cookbook' do
|
46
|
+
before(:each) do
|
47
|
+
raw_requirements['mysql'] = {'not-a-real-setting' => '~> 5.6.1'}
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should raise an error' do
|
51
|
+
expect {
|
52
|
+
subject
|
53
|
+
}.to raise_error Minimart::Error::InvalidInventoryError,
|
54
|
+
"Minimart could not find any requirements for 'mysql'"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#version_required?' do
|
60
|
+
context 'when the passed in cookbook was not specified in the local inventory' do
|
61
|
+
it 'should return true' do
|
62
|
+
expect(subject.version_required?('new-book', '0.0.1')).to eq true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when the passed in cookbook solves a requirement specified in the local inventory' do
|
67
|
+
it 'should return true' do
|
68
|
+
expect(subject.version_required?('mysql', '5.6.2')).to eq true
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when the passed in cookbook does not solve an explicitly defined requirement in the inventory' do
|
73
|
+
it 'should return false' do
|
74
|
+
expect(subject.version_required?('mysql', '5.5.0')).to eq false
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::Mirror::LocalStore do
|
4
|
+
|
5
|
+
subject { Minimart::Mirror::LocalStore.new(test_directory) }
|
6
|
+
|
7
|
+
describe '::new' do
|
8
|
+
context 'when a cookbook is found in the path' do
|
9
|
+
subject { Minimart::Mirror::LocalStore.new('spec/fixtures') }
|
10
|
+
|
11
|
+
it 'should add the cookbook to the store' do
|
12
|
+
expect(subject.installed?('sample_cookbook', '1.2.3')).to eq true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#add_cookbook_from_path" do
|
18
|
+
let(:sample_cookbook_path) { 'spec/fixtures/sample_cookbook' }
|
19
|
+
|
20
|
+
it 'should copy the sample cookbook' do
|
21
|
+
subject.add_cookbook_from_path(sample_cookbook_path)
|
22
|
+
new_cookbook_path = File.join(test_directory, 'sample_cookbook-1.2.3')
|
23
|
+
expect(Dir.exists?(new_cookbook_path)).to eq true
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should add the cookbook to the local store' do
|
27
|
+
subject.add_cookbook_from_path(sample_cookbook_path)
|
28
|
+
expect(subject.installed?('sample_cookbook', '1.2.3')).to eq true
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should store any download metadata' do
|
32
|
+
expect_any_instance_of(Minimart::Mirror::DownloadMetadata).to receive(:write).with('my' => 'data')
|
33
|
+
subject.add_cookbook_from_path(sample_cookbook_path, 'my' => 'data')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should store the metadata in the proper path' do
|
37
|
+
subject.add_cookbook_from_path(sample_cookbook_path)
|
38
|
+
expect(File.exists?(File.join(test_directory, 'sample_cookbook-1.2.3', '.minimart.json'))).to eq true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#installed?' do
|
43
|
+
context 'when a cookbook is installed' do
|
44
|
+
before(:each) do
|
45
|
+
subject.add_cookbook_to_store('sample_cookbook', '1.2.3')
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should return true for a matching version' do
|
49
|
+
expect(subject.installed?('sample_cookbook', '1.2.3')).to eq true
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should return false for a non-matching version' do
|
53
|
+
expect(subject.installed?('sample_cookbook', '10.0.0')).to eq false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when a cookbook is not installed' do
|
58
|
+
it 'should return false' do
|
59
|
+
expect(subject.installed?('sample_cookbook', '1.2.3')).to eq false
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::Mirror::Source do
|
4
|
+
|
5
|
+
let(:base_url) { 'https://fakesupermarket.com/chef' }
|
6
|
+
|
7
|
+
subject { Minimart::Mirror::Source.new(base_url) }
|
8
|
+
|
9
|
+
let(:raw_universe) { File.open('spec/fixtures/universe.json').read }
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
stub_request(:get, "#{base_url}/universe").
|
13
|
+
to_return(status: 200, body: raw_universe)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#find_cookbook' do
|
17
|
+
describe 'when a cookbook is present in the universe' do
|
18
|
+
it 'should return a matching cookbook' do
|
19
|
+
result = subject.find_cookbook('mysql', '5.6.1')
|
20
|
+
expect(result.name).to eq 'mysql'
|
21
|
+
expect(result.version).to eq '5.6.1'
|
22
|
+
expect(result.location_path).to eq 'https://supermarket.getchef.com/api/v1'
|
23
|
+
expect(result.download_url).to eq 'https://supermarket.getchef.com/api/v1/cookbooks/mysql/versions/5.6.1/download'
|
24
|
+
expect(result.dependencies).to eq("yum-mysql-community" => ">= 0.0.0")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'when a cookbook is not present in the universe' do
|
29
|
+
it 'should return nil' do
|
30
|
+
expect(subject.find_cookbook('madeup', '0.0.1')).to be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when the given universe does not exist' do
|
35
|
+
before(:each) do
|
36
|
+
stub_request(:get, "#{base_url}/universe").to_return(status: 404)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should raise the proper exception' do
|
40
|
+
expect {
|
41
|
+
subject.find_cookbook('mysql', '5.6.1')
|
42
|
+
}.to raise_error(
|
43
|
+
Minimart::Error::UniverseNotFoundError,
|
44
|
+
"no universe found for #{base_url}")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#to_s' do
|
50
|
+
it 'should return the base url' do
|
51
|
+
expect(subject.to_s).to eq base_url
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::Mirror::Sources do
|
4
|
+
|
5
|
+
describe '::new' do
|
6
|
+
let(:source_1) { 'https://supermarket.getchef.com' }
|
7
|
+
let(:source_2) { 'https://supermarket.internal.com' }
|
8
|
+
|
9
|
+
subject do
|
10
|
+
Minimart::Mirror::Sources.new([source_1, source_2])
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should build a source with the first url provided' do
|
14
|
+
expect(subject.map &:base_url ).to include source_1
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should build a source with the second url provided' do
|
18
|
+
expect(subject.map &:base_url ).to include source_2
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#find_cookbook' do
|
23
|
+
subject do
|
24
|
+
Minimart::Mirror::Sources.new(['https://supermarket.internal.com'])
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:cookbook) { double('cookbook', name: 'mysql', version: '1.0.0') }
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
allow_any_instance_of(Minimart::Mirror::Source).to receive(:cookbooks).and_return [cookbook]
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when a source has the given cookbook' do
|
34
|
+
it 'should return the cookbook' do
|
35
|
+
expect(subject.find_cookbook('mysql', '1.0.0')).to eq cookbook
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when the cookbook cannot be found' do
|
40
|
+
it 'should raise the proper exception' do
|
41
|
+
expect {
|
42
|
+
subject.find_cookbook('mysql', '2.0.0')
|
43
|
+
}.to raise_error(
|
44
|
+
Minimart::Error::CookbookNotFound,
|
45
|
+
"The cookbook mysql with the version 2.0.0 could not be found")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::Output do
|
4
|
+
|
5
|
+
let(:io) { StringIO.new }
|
6
|
+
let(:output) { Minimart::Output.new(io) }
|
7
|
+
|
8
|
+
subject { io.string }
|
9
|
+
|
10
|
+
describe '#puts' do
|
11
|
+
before(:each) { output.puts 'hello world' }
|
12
|
+
it { is_expected.to include 'hello world' }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#puts_red' do
|
16
|
+
before(:each) { output.puts_red 'hello world' }
|
17
|
+
it { is_expected.to include "\e[31mhello world\e[0m" }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#puts_green' do
|
21
|
+
before(:each) { output.puts_green 'hello world' }
|
22
|
+
it { is_expected.to include "\e[32mhello world\e[0m" }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#puts_yellow' do
|
26
|
+
before(:each) { output.puts_yellow 'hello world' }
|
27
|
+
it { is_expected.to include "\e[33mhello world\e[0m" }
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::Utils::Archive do
|
4
|
+
describe '::extract_archive' do
|
5
|
+
let(:archive) { 'spec/fixtures/sample_cookbook.tar.gz' }
|
6
|
+
|
7
|
+
let(:extracted_readme) do
|
8
|
+
File.join(test_directory, 'sample_cookbook', 'README.md')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should extract the contents of the archive to the passed in dir' do
|
12
|
+
Minimart::Utils::Archive.extract_archive(archive, test_directory)
|
13
|
+
expect(test_directory_contents).to include extracted_readme
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '::pack_archive' do
|
18
|
+
let(:path) { File.expand_path('spec/fixtures/sample_cookbook') }
|
19
|
+
let(:cookbook) { Minimart::Cookbook.from_path(path) }
|
20
|
+
let(:archive) { File.expand_path(File.join(test_directory, 'sample.tar.gz')) }
|
21
|
+
|
22
|
+
before(:each) { Minimart::Utils::Archive.pack_archive(cookbook, archive) }
|
23
|
+
|
24
|
+
it 'should create the archive' do
|
25
|
+
expect(File.exists?(archive)).to eq true
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should create a directory of the cookbook name in the top level of the archive' do
|
29
|
+
Minimart::Utils::Archive.extract_archive(archive, test_directory)
|
30
|
+
expect(Dir.exists?(File.join(test_directory, 'sample_cookbook')))
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should properly compress any files' do
|
34
|
+
Minimart::Utils::Archive.extract_archive(archive, test_directory)
|
35
|
+
expect(File.exists?(File.join(test_directory, 'sample_cookbook', 'README.md'))).to eq true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::Utils::FileHelper do
|
4
|
+
|
5
|
+
subject { Minimart::Utils::FileHelper }
|
6
|
+
|
7
|
+
let(:cookbook_path) { 'spec/fixtures/sample_cookbook/' }
|
8
|
+
|
9
|
+
describe '::cookbook_path_in_directory' do
|
10
|
+
describe 'when the path passed is a cookbook' do
|
11
|
+
it 'should return the path to the cookbook' do
|
12
|
+
expect(subject.cookbook_path_in_directory(cookbook_path)).to eq cookbook_path
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'when a cookbook is found one level deep in the directory structure' do
|
17
|
+
it 'should return the path to the cookbook' do
|
18
|
+
expect(subject.cookbook_path_in_directory('spec/fixtures')).to eq cookbook_path
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'when no cookbook is found' do
|
23
|
+
it 'should return nil' do
|
24
|
+
expect(subject.cookbook_path_in_directory('spec/')).to eq nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '::cookbook_in_path?' do
|
30
|
+
describe 'when the path passed is a cookbook' do
|
31
|
+
it 'should return true' do
|
32
|
+
expect(subject.cookbook_in_path?('spec/fixtures/sample_cookbook')).to eq true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'when the path passed is not a cookbook' do
|
37
|
+
it 'should return false' do
|
38
|
+
expect(subject.cookbook_in_path?('spec/')).to eq false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|