berkshelf 3.0.0.beta2 → 3.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile +0 -1
- data/Guardfile +0 -4
- data/README.md +1 -1
- data/Thorfile +2 -11
- data/berkshelf.gemspec +2 -5
- data/features/berksfile.feature +2 -10
- data/features/commands/apply.feature +31 -0
- data/features/{configure_command.feature → commands/configure.feature} +9 -11
- data/features/{contingent_command.feature → commands/contingent.feature} +10 -20
- data/features/{cookbook_command.feature → commands/cookbook.feature} +4 -11
- data/features/{init_command.feature → commands/init.feature} +10 -19
- data/features/{install_command.feature → commands/install.feature} +161 -82
- data/features/{list_command.feature → commands/list.feature} +4 -14
- data/features/{outdated_command.feature → commands/outdated.feature} +21 -63
- data/features/{package_command.feature → commands/package.feature} +11 -22
- data/features/{shelf → commands/shelf}/list.feature +3 -8
- data/features/{shelf → commands/shelf}/show.feature +5 -9
- data/features/{shelf → commands/shelf}/uninstall.feature +6 -10
- data/features/{show_command.feature → commands/show.feature} +13 -38
- data/features/commands/update.feature +48 -0
- data/features/commands/upload.feature +197 -0
- data/features/commands/vendor.feature +53 -0
- data/features/community_site.feature +39 -0
- data/features/config.feature +79 -9
- data/features/help.feature +10 -19
- data/features/json_formatter.feature +19 -44
- data/features/licenses.feature +27 -61
- data/features/lockfile.feature +120 -354
- data/features/resolver.feature +28 -0
- data/features/step_definitions/berksfile_steps.rb +39 -0
- data/features/step_definitions/chef/config_steps.rb +1 -1
- data/features/step_definitions/chef_server_steps.rb +27 -27
- data/features/step_definitions/config_steps.rb +3 -0
- data/features/step_definitions/filesystem_steps.rb +10 -0
- data/features/step_definitions/json_steps.rb +0 -7
- data/features/step_definitions/lockfile_steps.rb +53 -0
- data/features/step_definitions/utility_steps.rb +4 -4
- data/features/support/env.rb +1 -0
- data/generator_files/Berksfile.erb +1 -1
- data/generator_files/README.md.erb +62 -6
- data/generator_files/Vagrantfile.erb +15 -4
- data/lib/berkshelf.rb +2 -4
- data/lib/berkshelf/api_client.rb +5 -7
- data/lib/berkshelf/berksfile.rb +24 -20
- data/lib/berkshelf/cached_cookbook.rb +8 -1
- data/lib/berkshelf/cli.rb +5 -10
- data/lib/berkshelf/community_rest.rb +4 -5
- data/lib/berkshelf/config.rb +8 -2
- data/lib/berkshelf/cookbook_store.rb +9 -14
- data/lib/berkshelf/dependency.rb +16 -13
- data/lib/berkshelf/errors.rb +15 -1
- data/lib/berkshelf/formatters/json.rb +1 -1
- data/lib/berkshelf/init_generator.rb +17 -3
- data/lib/berkshelf/installer.rb +12 -1
- data/lib/berkshelf/logger.rb +7 -4
- data/lib/berkshelf/resolver.rb +1 -1
- data/lib/berkshelf/version.rb +1 -1
- data/spec/spec_helper.rb +0 -9
- data/spec/support/chef_server.rb +24 -7
- data/spec/unit/berkshelf/api_client/remote_cookbook_spec.rb +3 -3
- data/spec/unit/berkshelf/berksfile_spec.rb +35 -1
- data/spec/unit/berkshelf/cached_cookbook_spec.rb +8 -0
- data/spec/unit/berkshelf/community_rest_spec.rb +76 -25
- data/spec/unit/berkshelf/cookbook_generator_spec.rb +9 -3
- data/spec/unit/berkshelf/dependency_spec.rb +16 -1
- data/spec/unit/berkshelf/init_generator_spec.rb +71 -7
- metadata +44 -116
- data/.cane +0 -4
- data/features/apply_command.feature +0 -40
- data/features/groups_install.feature +0 -113
- data/features/update_command.feature +0 -136
- data/features/upload_command.feature +0 -327
- data/features/vendor_command.feature +0 -83
- data/lib/berkshelf/chef.rb +0 -7
- data/lib/berkshelf/chef/cookbook.rb +0 -5
- data/lib/berkshelf/chef/cookbook/chefignore.rb +0 -75
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_download/unpacks_the_archive.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/raises_a_CommunitySiteError_error_on_any_non_200_or_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/raises_a_CookbookNotFound_error_on_a_404_response_for_a_non-existent_cookbook.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/raises_a_CookbookNotFound_error_on_a_404_response_for_a_non-existent_version.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_find/returns_the_cookbook_and_version_information.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_latest_version/raises_a_CommunitySiteError_error_on_any_non_200_or_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_latest_version/raises_a_CookbookNotFound_error_on_a_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_latest_version/returns_the_version_number_of_the_latest_version_of_the_cookbook.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_satisfy/returns_the_version_number_of_the_best_solution.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_versions/raises_a_CommunitySiteError_error_on_any_non_200_or_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_versions/raises_a_CookbookNotFound_error_on_a_404_response.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_CommunityREST/_versions/returns_an_array_containing_an_item_for_each_version.json +0 -1
- data/spec/fixtures/cassettes/Berkshelf_Resolver/_initialize/adds_the_dependencies_of_the_dependency_as_dependencies.yml +0 -3694
- data/spec/fixtures/cassettes/Berkshelf_Resolver/_initialize/adds_the_dependencies_of_the_source_as_sources.yml +0 -3829
- data/spec/unit/berkshelf/chef/cookbook/chefignore_spec.rb +0 -19
data/lib/berkshelf/resolver.rb
CHANGED
@@ -68,7 +68,7 @@ module Berkshelf
|
|
68
68
|
graph.populate_store
|
69
69
|
graph.populate(berksfile.sources)
|
70
70
|
|
71
|
-
Solve.it!(graph, demand_array).collect do |name, version|
|
71
|
+
Solve.it!(graph, demand_array, ENV['DEBUG_RESOLVER'] ? { ui: Berkshelf.ui } : {}).collect do |name, version|
|
72
72
|
dependency = get_demand(name) || Dependency.new(berksfile, name, locked_version: version)
|
73
73
|
[ name, version, dependency ]
|
74
74
|
end
|
data/lib/berkshelf/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -3,19 +3,10 @@ require 'spork'
|
|
3
3
|
Spork.prefork do
|
4
4
|
require 'rspec'
|
5
5
|
require 'webmock/rspec'
|
6
|
-
require 'vcr'
|
7
6
|
require 'berkshelf/api/rspec'
|
8
7
|
|
9
8
|
Dir['spec/support/**/*.rb'].each { |f| require File.expand_path(f) }
|
10
9
|
|
11
|
-
VCR.configure do |config|
|
12
|
-
config.configure_rspec_metadata!
|
13
|
-
config.cassette_library_dir = 'spec/fixtures/cassettes'
|
14
|
-
config.hook_into :webmock
|
15
|
-
config.default_cassette_options = { record: :new_episodes }
|
16
|
-
config.ignore_localhost = true
|
17
|
-
end
|
18
|
-
|
19
10
|
RSpec.configure do |config|
|
20
11
|
config.include Berkshelf::RSpec::FileSystemMatchers
|
21
12
|
config.include Berkshelf::RSpec::ChefAPI
|
data/spec/support/chef_server.rb
CHANGED
@@ -53,30 +53,47 @@ module Berkshelf::RSpec
|
|
53
53
|
ChefServer.server
|
54
54
|
end
|
55
55
|
|
56
|
-
def chef_client(name, hash =
|
56
|
+
def chef_client(name, hash = {})
|
57
57
|
load_data(:clients, name, hash)
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
61
|
-
|
60
|
+
def chef_cookbook(name, hash = {})
|
61
|
+
chef_server.load_data({ 'cookbooks' => { name => hash }})
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
64
|
+
def chef_cookbooks
|
65
|
+
chef_server.data_store.list(['cookbooks']).inject({}) do |hash, name|
|
66
|
+
hash[name] = chef_server.data_store.list(['cookbooks', name])
|
67
|
+
hash
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def chef_data_bag(name, hash = {})
|
72
|
+
chef_server.load_data({ 'data' => { name => hash }})
|
73
|
+
end
|
74
|
+
|
75
|
+
def chef_environment(name, hash = {})
|
65
76
|
load_data(:environments, name, hash)
|
66
77
|
end
|
67
78
|
|
68
|
-
def
|
79
|
+
def chef_environment_locks(name)
|
80
|
+
JSON.parse(chef_server.data_store.get(['environments', name]))['cookbook_versions']
|
81
|
+
rescue ChefZero::DataStore::DataNotFoundError
|
82
|
+
{}
|
83
|
+
end
|
84
|
+
|
85
|
+
def chef_node(name, hash = {})
|
69
86
|
load_data(:nodes, name, hash)
|
70
87
|
end
|
71
88
|
|
72
|
-
def chef_role(name, hash =
|
89
|
+
def chef_role(name, hash = {})
|
73
90
|
load_data(:roles, name, hash)
|
74
91
|
end
|
75
92
|
|
76
93
|
private
|
77
94
|
|
78
95
|
def load_data(key, name, hash)
|
79
|
-
|
96
|
+
chef_server.load_data({ key.to_s => { name => JSON.generate(hash) }})
|
80
97
|
end
|
81
98
|
end
|
82
99
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Berkshelf::APIClient::RemoteCookbook do
|
4
|
-
|
5
|
-
|
4
|
+
let(:name) { "ruby" }
|
5
|
+
let(:version) { "1.2.3" }
|
6
6
|
let(:dependencies) { double('dependencies') }
|
7
7
|
let(:platforms) { double('platforms') }
|
8
8
|
let(:location_type) { "chef_server" }
|
9
9
|
let(:location_path) { "http://localhost:8080" }
|
10
10
|
|
11
11
|
let(:attributes) do
|
12
|
-
|
12
|
+
{ dependencies: dependencies, platforms: platforms, location_path: location_path, location_type: location_type }
|
13
13
|
end
|
14
14
|
|
15
15
|
subject { described_class.new(name, version, attributes) }
|
@@ -8,7 +8,7 @@ describe Berkshelf::Berksfile do
|
|
8
8
|
it "returns an array including the default sources" do
|
9
9
|
expect(subject).to be_a(Array)
|
10
10
|
expect(subject).to have(1).item
|
11
|
-
expect(subject.map(&:to_s)).to include("
|
11
|
+
expect(subject.map(&:to_s)).to include("https://api.berkshelf.com")
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -449,6 +449,40 @@ describe Berkshelf::Berksfile do
|
|
449
449
|
upload
|
450
450
|
end
|
451
451
|
end
|
452
|
+
|
453
|
+
context 'when a client name is passed as an option' do
|
454
|
+
let(:options) do
|
455
|
+
{
|
456
|
+
client_name: 'passed-in-client-name'
|
457
|
+
}
|
458
|
+
end
|
459
|
+
let(:ridley_options) do
|
460
|
+
default_ridley_options.merge(
|
461
|
+
{ server_url: 'http://configured-chef-server/', client_name: 'passed-in-client-name'})
|
462
|
+
end
|
463
|
+
|
464
|
+
it 'uses the passed in :client_name' do
|
465
|
+
Ridley.should_receive(:open).with(ridley_options)
|
466
|
+
upload
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
470
|
+
context 'when a client key is passed as an option' do
|
471
|
+
let(:options) do
|
472
|
+
{
|
473
|
+
client_key: 'passed-in-client-key'
|
474
|
+
}
|
475
|
+
end
|
476
|
+
let(:ridley_options) do
|
477
|
+
default_ridley_options.merge(
|
478
|
+
{ server_url: 'http://configured-chef-server/', client_key: 'passed-in-client-key'})
|
479
|
+
end
|
480
|
+
|
481
|
+
it 'uses the passed in :client_key' do
|
482
|
+
Ridley.should_receive(:open).with(ridley_options)
|
483
|
+
upload
|
484
|
+
end
|
485
|
+
end
|
452
486
|
end
|
453
487
|
|
454
488
|
describe "#apply" do
|
@@ -30,6 +30,14 @@ describe Berkshelf::CachedCookbook do
|
|
30
30
|
expect(described_class.from_store_path(path)).to be_nil
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
context 'given an already cached cookbook' do
|
35
|
+
let!(:cached) { described_class.from_store_path(path) }
|
36
|
+
|
37
|
+
it 'returns the cached cookbook instance' do
|
38
|
+
expect(described_class.from_store_path(path)).to eq(cached)
|
39
|
+
end
|
40
|
+
end
|
33
41
|
end
|
34
42
|
|
35
43
|
describe '::checksum' do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Berkshelf::CommunityREST
|
3
|
+
describe Berkshelf::CommunityREST do
|
4
4
|
describe "ClassMethods" do
|
5
5
|
describe "::unpack" do
|
6
6
|
let(:target) { '/foo/bar' }
|
@@ -73,85 +73,136 @@ describe Berkshelf::CommunityREST, vcr: { record: :new_episodes, serialize_with:
|
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'unpacks the archive' do
|
76
|
+
stub_request(:get, "#{api_uri}/cookbooks/bacon/versions/1_0_0").to_return(
|
77
|
+
status: 200,
|
78
|
+
body: '{ "cookbook": "/path/to/cookbook", "version": "1.0.0" }',
|
79
|
+
headers: { 'Content-Type' => 'application/json' },
|
80
|
+
)
|
81
|
+
|
76
82
|
Berkshelf::CommunityREST.should_receive(:unpack).with('/foo/bar').once.and_return('/foo/nginx')
|
77
83
|
archive.should_receive(:unlink).once
|
78
84
|
|
79
|
-
subject.download('
|
85
|
+
subject.download('bacon', '1.0.0')
|
80
86
|
end
|
81
87
|
end
|
82
88
|
|
83
89
|
describe '#find' do
|
84
90
|
it 'returns the cookbook and version information' do
|
85
|
-
|
91
|
+
stub_request(:get, "#{api_uri}/cookbooks/bacon/versions/1_0_0").to_return(
|
92
|
+
status: 200,
|
93
|
+
body: '{ "cookbook": "/path/to/cookbook", "version": "1.0.0" }',
|
94
|
+
headers: { 'Content-Type' => 'application/json' },
|
95
|
+
)
|
96
|
+
|
97
|
+
result = subject.find('bacon', '1.0.0')
|
86
98
|
|
87
|
-
expect(result.cookbook).to eq('
|
88
|
-
expect(result.version).to eq('1.
|
99
|
+
expect(result.cookbook).to eq('/path/to/cookbook')
|
100
|
+
expect(result.version).to eq('1.0.0')
|
89
101
|
end
|
90
102
|
|
91
103
|
it 'raises a CookbookNotFound error on a 404 response for a non-existent cookbook' do
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
104
|
+
stub_request(:get, "#{api_uri}/cookbooks/not_real/versions/1_0_0").to_return(
|
105
|
+
status: 404,
|
106
|
+
body: nil,
|
107
|
+
)
|
96
108
|
|
97
|
-
it 'raises a CookbookNotFound error on a 404 response for a non-existent version' do
|
98
109
|
expect {
|
99
|
-
subject.find('
|
110
|
+
subject.find('not_real', '1.0.0')
|
100
111
|
}.to raise_error(Berkshelf::CookbookNotFound)
|
101
112
|
end
|
102
113
|
|
103
|
-
# @warn if you re-record the VCR cassettes, you'll need to manually change the
|
104
|
-
# HTTP Response Code in the YAML file to 500
|
105
114
|
it 'raises a CommunitySiteError error on any non 200 or 404 response' do
|
115
|
+
stub_request(:get, "#{api_uri}/cookbooks/not_real/versions/1_0_0").to_return(
|
116
|
+
status: 500,
|
117
|
+
body: nil,
|
118
|
+
)
|
119
|
+
|
106
120
|
expect {
|
107
|
-
subject.find('
|
121
|
+
subject.find('not_real', '1.0.0')
|
108
122
|
}.to raise_error(Berkshelf::CommunitySiteError)
|
109
123
|
end
|
110
124
|
end
|
111
125
|
|
112
126
|
describe '#latest_version' do
|
113
127
|
it 'returns the version number of the latest version of the cookbook' do
|
114
|
-
|
128
|
+
stub_request(:get, "#{api_uri}/cookbooks/bacon").to_return(
|
129
|
+
status: 200,
|
130
|
+
body: '{ "latest_version": "1.0.0" }',
|
131
|
+
headers: { 'Content-Type' => 'application/json' }
|
132
|
+
)
|
133
|
+
|
134
|
+
latest = subject.latest_version('bacon')
|
135
|
+
expect(latest).to eq('1.0.0')
|
115
136
|
end
|
116
137
|
|
117
138
|
it 'raises a CookbookNotFound error on a 404 response' do
|
139
|
+
stub_request(:get, "#{api_uri}/cookbooks/not_real").to_return(
|
140
|
+
status: 404,
|
141
|
+
body: nil,
|
142
|
+
)
|
143
|
+
|
118
144
|
expect {
|
119
|
-
subject.latest_version('
|
145
|
+
subject.latest_version('not_real')
|
120
146
|
}.to raise_error(Berkshelf::CookbookNotFound)
|
121
147
|
end
|
122
148
|
|
123
|
-
# @warn if you re-record the VCR cassettes, you'll need to manually change the
|
124
|
-
# HTTP Response Code in the YAML file to 500
|
125
149
|
it 'raises a CommunitySiteError error on any non 200 or 404 response' do
|
150
|
+
stub_request(:get, "#{api_uri}/cookbooks/not_real").to_return(
|
151
|
+
status: 500,
|
152
|
+
body: nil,
|
153
|
+
)
|
154
|
+
|
126
155
|
expect {
|
127
|
-
subject.latest_version('
|
156
|
+
subject.latest_version('not_real')
|
128
157
|
}.to raise_error(Berkshelf::CommunitySiteError)
|
129
158
|
end
|
130
159
|
end
|
131
160
|
|
132
161
|
describe '#versions' do
|
133
162
|
it 'returns an array containing an item for each version' do
|
134
|
-
|
163
|
+
stub_request(:get, "#{api_uri}/cookbooks/bacon").to_return(
|
164
|
+
status: 200,
|
165
|
+
body: '{ "versions": ["/bacon/versions/1_0_0", "/bacon/versions/2_0_0"] }',
|
166
|
+
headers: { 'Content-Type' => 'application/json' }
|
167
|
+
)
|
168
|
+
|
169
|
+
versions = subject.versions('bacon')
|
170
|
+
expect(versions.size).to eq(2)
|
135
171
|
end
|
136
172
|
|
137
173
|
it 'raises a CookbookNotFound error on a 404 response' do
|
174
|
+
stub_request(:get, "#{api_uri}/cookbooks/not_real").to_return(
|
175
|
+
status: 404,
|
176
|
+
body: nil,
|
177
|
+
)
|
178
|
+
|
138
179
|
expect {
|
139
|
-
subject.versions('
|
180
|
+
subject.versions('not_real')
|
140
181
|
}.to raise_error(Berkshelf::CookbookNotFound)
|
141
182
|
end
|
142
183
|
|
143
|
-
# @warn if you re-record the VCR cassettes, you'll need to manually change the
|
144
|
-
# HTTP Response Code in the YAML file to 500
|
145
184
|
it 'raises a CommunitySiteError error on any non 200 or 404 response' do
|
185
|
+
stub_request(:get, "#{api_uri}/cookbooks/not_real").to_return(
|
186
|
+
status: 500,
|
187
|
+
body: nil,
|
188
|
+
)
|
189
|
+
|
146
190
|
expect {
|
147
|
-
subject.versions('
|
191
|
+
subject.versions('not_real')
|
148
192
|
}.to raise_error(Berkshelf::CommunitySiteError)
|
149
193
|
end
|
150
194
|
end
|
151
195
|
|
152
196
|
describe '#satisfy' do
|
153
197
|
it 'returns the version number of the best solution' do
|
154
|
-
|
198
|
+
stub_request(:get, "#{api_uri}/cookbooks/bacon").to_return(
|
199
|
+
status: 200,
|
200
|
+
body: '{ "versions": ["/bacon/versions/1_0_0", "/bacon/versions/2_0_0"] }',
|
201
|
+
headers: { 'Content-Type' => 'application/json' }
|
202
|
+
)
|
203
|
+
|
204
|
+
result = subject.satisfy('bacon', '= 1.0.0')
|
205
|
+
expect(result).to eq('1.0.0')
|
155
206
|
end
|
156
207
|
end
|
157
208
|
|
@@ -14,7 +14,7 @@ describe Berkshelf::CookbookGenerator do
|
|
14
14
|
capture(:stdout) { Berkshelf::CookbookGenerator.new([target, name]).invoke_all }
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
it "generates a new cookbook" do
|
18
18
|
expect(target).to have_structure {
|
19
19
|
directory 'attributes'
|
20
20
|
directory 'files' do
|
@@ -39,7 +39,13 @@ describe Berkshelf::CookbookGenerator do
|
|
39
39
|
contains 'All rights reserved - Do Not Redistribute'
|
40
40
|
end
|
41
41
|
file 'README.md' do
|
42
|
-
contains '
|
42
|
+
contains 'sparkle_motion cookbook'
|
43
|
+
contains '======================='
|
44
|
+
contains '- `toaster` - sparkle_motion needs toaster to brown your bagel.'
|
45
|
+
contains '#### sparkle_motion::default'
|
46
|
+
contains " <td><tt>['sparkle_motion']['bacon']</tt></td>"
|
47
|
+
contains "Just include `sparkle_motion` in your node's `run_list`:"
|
48
|
+
contains ' "recipe[sparkle_motion]"'
|
43
49
|
contains 'Author:: YOUR_NAME (<YOUR_EMAIL>)'
|
44
50
|
end
|
45
51
|
file 'metadata.rb' do
|
@@ -50,7 +56,7 @@ describe Berkshelf::CookbookGenerator do
|
|
50
56
|
contains "description 'Installs/Configures sparkle_motion'"
|
51
57
|
end
|
52
58
|
file 'Berksfile' do
|
53
|
-
contains 'source "
|
59
|
+
contains 'source "https://api.berkshelf.com"'
|
54
60
|
contains 'metadata'
|
55
61
|
end
|
56
62
|
file 'Gemfile'
|
@@ -215,7 +215,7 @@ describe Berkshelf::Dependency do
|
|
215
215
|
end
|
216
216
|
|
217
217
|
it 'includes the locked version' do
|
218
|
-
subject.stub(
|
218
|
+
subject.stub(locked_version: double('cached', to_s: '1.2.3'))
|
219
219
|
|
220
220
|
expect(hash).to have_key(:locked_version)
|
221
221
|
expect(hash[:locked_version]).to eq('1.2.3')
|
@@ -275,4 +275,19 @@ describe Berkshelf::Dependency do
|
|
275
275
|
it { should be_false }
|
276
276
|
end
|
277
277
|
end
|
278
|
+
|
279
|
+
describe "#path_location?" do
|
280
|
+
let(:options) { Hash.new }
|
281
|
+
subject { described_class.new(berksfile, cookbook_name, options).path_location? }
|
282
|
+
|
283
|
+
context "when the location is a PathLocation" do
|
284
|
+
let(:options) { { path: fixtures_path.join("cookbooks", "example_cookbook") } }
|
285
|
+
it { should be_true }
|
286
|
+
end
|
287
|
+
|
288
|
+
context "when the location is not a PathLocation" do
|
289
|
+
let(:options) { { github: "RiotGames/berkshelf" } }
|
290
|
+
it { should be_false }
|
291
|
+
end
|
292
|
+
end
|
278
293
|
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Berkshelf::InitGenerator
|
3
|
+
describe Berkshelf::InitGenerator do
|
4
4
|
let(:target) { tmp_path.join("some_cookbook") }
|
5
5
|
let(:resolver) { double('resolver') }
|
6
6
|
let(:kitchen_generator) { double('kitchen-generator', invoke_all: nil) }
|
7
7
|
|
8
8
|
before do
|
9
9
|
Kitchen::Generator::Init.stub(:new).with(any_args()).and_return(kitchen_generator)
|
10
|
+
FileUtils.mkdir_p(target)
|
11
|
+
File.open(File.join(target, 'metadata.rb'), 'w') do |f|
|
12
|
+
f.write("name 'some_cookbook'")
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
context 'with default options' do
|
@@ -25,8 +29,11 @@ describe Berkshelf::InitGenerator, vcr: { record: :new_episodes, serialize_with:
|
|
25
29
|
end
|
26
30
|
file 'Vagrantfile' do
|
27
31
|
contains 'recipe[some_cookbook::default]'
|
32
|
+
contains ' config.omnibus.chef_version = :latest'
|
33
|
+
contains 'config.vm.box = "opscode_ubuntu-12.04_provisionerless"'
|
34
|
+
contains 'config.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box"'
|
28
35
|
end
|
29
|
-
|
36
|
+
file 'chefignore'
|
30
37
|
}
|
31
38
|
end
|
32
39
|
end
|
@@ -46,13 +53,17 @@ describe Berkshelf::InitGenerator, vcr: { record: :new_episodes, serialize_with:
|
|
46
53
|
end
|
47
54
|
end
|
48
55
|
|
56
|
+
context 'with no metadata' do
|
57
|
+
before do
|
58
|
+
FileUtils.rm(File.join(target, 'metadata.rb'))
|
59
|
+
expect {
|
60
|
+
Berkshelf::InitGenerator.new([target]).invoke_all
|
61
|
+
}.to raise_error(Berkshelf::NotACookbook)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
49
65
|
context 'with a metadata entry in the Berksfile' do
|
50
66
|
before(:each) do
|
51
|
-
Dir.mkdir target
|
52
|
-
File.open(target.join('metadata.rb'), 'w+') do |f|
|
53
|
-
f.write ''
|
54
|
-
end
|
55
|
-
|
56
67
|
capture(:stdout) {
|
57
68
|
Berkshelf::InitGenerator.new([target], metadata_entry: true).invoke_all
|
58
69
|
}
|
@@ -164,6 +175,59 @@ describe Berkshelf::InitGenerator, vcr: { record: :new_episodes, serialize_with:
|
|
164
175
|
end
|
165
176
|
end
|
166
177
|
|
178
|
+
context "given the 'vagrant.omnibus.enabled' option set to false" do
|
179
|
+
before do
|
180
|
+
Berkshelf::Config.instance.vagrant.omnibus.enabled = false
|
181
|
+
capture(:stdout) {
|
182
|
+
Berkshelf::InitGenerator.new([target]).invoke_all
|
183
|
+
}
|
184
|
+
end
|
185
|
+
|
186
|
+
it "generates a Vagrantfile without the 'config.omnibus.chef_version' value set" do
|
187
|
+
expect(target).to have_structure {
|
188
|
+
file 'Vagrantfile' do
|
189
|
+
contains "#config.omnibus.chef_version"
|
190
|
+
end
|
191
|
+
}
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
context "given the 'vagrant.omnibus.version' option set" do
|
196
|
+
before do
|
197
|
+
Berkshelf::Config.instance.vagrant.omnibus.enabled = true
|
198
|
+
Berkshelf::Config.instance.vagrant.omnibus.version = "11.4.4"
|
199
|
+
capture(:stdout) {
|
200
|
+
Berkshelf::InitGenerator.new([target]).invoke_all
|
201
|
+
}
|
202
|
+
end
|
203
|
+
|
204
|
+
it "generates a Vagrantfile with the 'config.omnibus.chef_version' value set" do
|
205
|
+
expect(target).to have_structure {
|
206
|
+
file 'Vagrantfile' do
|
207
|
+
contains " config.omnibus.chef_version = \"11.4.4\""
|
208
|
+
end
|
209
|
+
}
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
context "given the 'vagrant.omnibus.version' option set to 'latest'" do
|
214
|
+
before do
|
215
|
+
Berkshelf::Config.instance.vagrant.omnibus.enabled = true
|
216
|
+
Berkshelf::Config.instance.vagrant.omnibus.version = "latest"
|
217
|
+
capture(:stdout) {
|
218
|
+
Berkshelf::InitGenerator.new([target]).invoke_all
|
219
|
+
}
|
220
|
+
end
|
221
|
+
|
222
|
+
it "generates a Vagrantfile with the 'config.omnibus.chef_version' value set to :latest" do
|
223
|
+
expect(target).to have_structure {
|
224
|
+
file 'Vagrantfile' do
|
225
|
+
contains " config.omnibus.chef_version = :latest"
|
226
|
+
end
|
227
|
+
}
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
167
231
|
context 'with the chef_minitest option true' do
|
168
232
|
before(:each) do
|
169
233
|
Berkshelf::Resolver.stub(:resolve) { resolver }
|