berkshelf 1.4.0.rc1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/berkshelf.gemspec +2 -1
- data/features/contingent_command.feature +18 -0
- data/features/cookbook_command.feature +13 -11
- data/features/info_command.feature +39 -0
- data/features/step_definitions/filesystem_steps.rb +32 -0
- data/features/step_definitions/gem_steps.rb +3 -2
- data/features/support/env.rb +2 -0
- data/generator_files/Berksfile.erb +5 -0
- data/generator_files/Vagrantfile.erb +10 -0
- data/generator_files/default_test.rb.erb +11 -0
- data/generator_files/helpers.rb.erb +7 -0
- data/lib/berkshelf.rb +4 -3
- data/lib/berkshelf/berksfile.rb +5 -15
- data/lib/berkshelf/cached_cookbook.rb +18 -0
- data/lib/berkshelf/chef/config.rb +21 -26
- data/lib/berkshelf/cli.rb +40 -5
- data/lib/berkshelf/community_rest.rb +17 -1
- data/lib/berkshelf/cookbook_generator.rb +4 -0
- data/lib/berkshelf/cookbook_source.rb +21 -18
- data/lib/berkshelf/init_generator.rb +13 -3
- data/lib/berkshelf/locations/github_location.rb +1 -1
- data/lib/berkshelf/locations/path_location.rb +1 -1
- data/lib/berkshelf/resolver.rb +10 -6
- data/lib/berkshelf/test.rb +37 -0
- data/lib/berkshelf/version.rb +1 -1
- data/spec/spec_helper.rb +5 -1
- data/spec/unit/berkshelf/community_rest_spec.rb +1 -0
- data/spec/unit/berkshelf/cookbook_source_spec.rb +201 -181
- data/spec/unit/berkshelf/init_generator_spec.rb +40 -1
- data/spec/unit/berkshelf/locations/path_location_spec.rb +10 -0
- data/spec/unit/berkshelf/resolver_spec.rb +6 -7
- data/spec/unit/berkshelf/ui_spec.rb +2 -1
- data/spec/unit/chef/config_spec.rb +79 -4
- metadata +34 -8
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Berkshelf::InitGenerator do
|
3
|
+
describe Berkshelf::InitGenerator, vcr: { record: :new_episodes, serialize_with: :json } do
|
4
4
|
subject { described_class }
|
5
5
|
|
6
6
|
let(:target) { tmp_path.join("some_cookbook") }
|
7
|
+
let(:resolver) { double('resolver') }
|
7
8
|
|
8
9
|
context "with default options" do
|
9
10
|
before(:each) do
|
@@ -157,4 +158,42 @@ describe Berkshelf::InitGenerator do
|
|
157
158
|
}
|
158
159
|
end
|
159
160
|
end
|
161
|
+
|
162
|
+
context "with the chef_minitest option true" do
|
163
|
+
before(:each) do
|
164
|
+
Berkshelf::Resolver.stub(:resolve) { resolver }
|
165
|
+
pending "Runs fine with no mock for the HTTP call on the first pass, subsequent passes throw errors"
|
166
|
+
capture(:stdout) {
|
167
|
+
subject.new([target], chef_minitest: true).invoke_all
|
168
|
+
}
|
169
|
+
end
|
170
|
+
|
171
|
+
specify do
|
172
|
+
target.should have_structure {
|
173
|
+
file "Berksfile" do
|
174
|
+
contains "cookbook \"minitest-handler\""
|
175
|
+
end
|
176
|
+
file "Vagrantfile" do
|
177
|
+
contains "\"recipe[minitest-handler::default]\""
|
178
|
+
end
|
179
|
+
directory "files" do
|
180
|
+
directory "default" do
|
181
|
+
directory "tests" do
|
182
|
+
directory "minitest" do
|
183
|
+
file "default_test.rb" do
|
184
|
+
contains "describe 'some_cookbook::default' do"
|
185
|
+
contains "include Helpers::Some_cookbook"
|
186
|
+
end
|
187
|
+
directory "support" do
|
188
|
+
file "helpers.rb" do
|
189
|
+
contains "module Some_cookbook"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
}
|
197
|
+
end
|
198
|
+
end
|
160
199
|
end
|
@@ -4,6 +4,16 @@ describe Berkshelf::PathLocation do
|
|
4
4
|
let(:complacent_constraint) { double('comp-vconstraint', satisfies?: true) }
|
5
5
|
let(:path) { fixtures_path.join("cookbooks", "example_cookbook").to_s }
|
6
6
|
|
7
|
+
describe "ClassMethods" do
|
8
|
+
describe "::new" do
|
9
|
+
it "assigns the value of :path to @path" do
|
10
|
+
obj = described_class.new("nginx", complacent_constraint, path: path)
|
11
|
+
|
12
|
+
obj.path.should eql(path)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
7
17
|
subject { described_class.new("nginx", complacent_constraint, path: path) }
|
8
18
|
|
9
19
|
describe "#download" do
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Berkshelf::Resolver, :chef_server, vcr: { record: :new_episodes, serialize_with: :yaml } do
|
4
|
+
let(:downloader ) { Berkshelf::Downloader.new(Berkshelf.cookbook_store) }
|
5
|
+
let(:berksfile) { double(downloader: downloader) }
|
4
6
|
let(:source) do
|
5
7
|
double('source',
|
6
8
|
name: 'mysql',
|
@@ -20,30 +22,27 @@ describe Berkshelf::Resolver, :chef_server, vcr: { record: :new_episodes, serial
|
|
20
22
|
subject { described_class }
|
21
23
|
|
22
24
|
describe "::initialize" do
|
23
|
-
let(:downloader) { Berkshelf::Downloader.new(Berkshelf.cookbook_store) }
|
24
|
-
|
25
25
|
it "adds the specified sources to the sources hash" do
|
26
|
-
resolver = subject.new(
|
26
|
+
resolver = subject.new(berksfile, sources: [source], skip_dependencies: true)
|
27
27
|
|
28
28
|
resolver.should have_source(source.name)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should not add dependencies if requested" do
|
32
|
-
resolver = subject.new(
|
32
|
+
resolver = subject.new(berksfile, sources: [source], skip_dependencies: true)
|
33
33
|
|
34
34
|
resolver.should_not have_source("nginx")
|
35
35
|
end
|
36
36
|
|
37
37
|
it "adds the dependencies of the source as sources" do
|
38
|
-
resolver = subject.new(
|
38
|
+
resolver = subject.new(berksfile, sources: [source])
|
39
39
|
|
40
40
|
resolver.should have_source("nginx")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
subject { described_class.new(downloader) }
|
45
|
+
subject { described_class.new(berksfile) }
|
47
46
|
|
48
47
|
describe "#add_source" do
|
49
48
|
let(:package_version) { double('package-version', dependencies: Array.new) }
|
@@ -92,7 +92,8 @@ describe Thor::Shell::Color do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'calls #say with yellow coloring' do
|
95
|
-
stdout.
|
95
|
+
stdout.stub :tty?
|
96
|
+
stdout.should_receive(:puts).with("warning")
|
96
97
|
stdout.should_receive(:flush).with(no_args())
|
97
98
|
subject.warn 'warning'
|
98
99
|
end
|
@@ -1,9 +1,84 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Berkshelf::Chef::Config do
|
4
|
-
|
5
|
-
subject { described_class.path }
|
4
|
+
subject { described_class }
|
6
5
|
|
7
|
-
|
6
|
+
describe '::path' do
|
7
|
+
let(:path) { '/fake/path/for/.chef' }
|
8
|
+
let(:config) { File.join(path, 'knife.rb') }
|
9
|
+
|
10
|
+
before do
|
11
|
+
ENV.stub(:[]).and_return(nil)
|
12
|
+
|
13
|
+
File.stub(:exists?).with(any_args()).and_return(false)
|
14
|
+
File.stub(:exists?).with(config).and_return(true)
|
15
|
+
|
16
|
+
subject.instance_variable_set(:@path, nil)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'uses $BERKSHELF_CHEF_CONFIG' do
|
20
|
+
ENV.stub(:[]).with('BERKSHELF_CHEF_CONFIG').and_return(config)
|
21
|
+
expect(subject.path).to eq(config)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'uses $KNIFE_HOME' do
|
25
|
+
ENV.stub(:[]).with('KNIFE_HOME').and_return(path)
|
26
|
+
expect(subject.path).to eq(config)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'uses ::working_dir' do
|
30
|
+
Berkshelf::Chef::Config.stub(:working_dir).and_return(path)
|
31
|
+
expect(subject.path).to eq(config)
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'an ascending search' do
|
35
|
+
context 'with multiple .chef directories' do
|
36
|
+
let(:path) { '/fake/.chef/path/with/multiple/.chef/directories' }
|
37
|
+
|
38
|
+
before do
|
39
|
+
Berkshelf::Chef::Config.stub(:working_dir).and_return(path)
|
40
|
+
File.stub(:exists?).and_return(false)
|
41
|
+
File.stub(:exists?).with('/fake/.chef/knife.rb').and_return(true)
|
42
|
+
File.stub(:exists?).with('/fake/.chef/path/with/multiple/.chef/knife.rb').and_return(true)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'chooses the closest path' do
|
46
|
+
expect(subject.path).to eq('/fake/.chef/path/with/multiple/.chef/knife.rb')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'with the current directory as .chef' do
|
51
|
+
let(:path) { '/fake/.chef' }
|
52
|
+
|
53
|
+
before do
|
54
|
+
Berkshelf::Chef::Config.stub(:working_dir).and_return(path)
|
55
|
+
File.stub(:exists?).and_return(false)
|
56
|
+
File.stub(:exists?).with('/fake/.chef/knife.rb').and_return(true)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'uses the current directory' do
|
60
|
+
expect(subject.path).to eq('/fake/.chef/knife.rb')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'with .chef at the top-level' do
|
65
|
+
let(:path) { '/.chef/some/random/sub/directories' }
|
66
|
+
|
67
|
+
before do
|
68
|
+
Berkshelf::Chef::Config.stub(:working_dir).and_return(path)
|
69
|
+
File.stub(:exists?).and_return(false)
|
70
|
+
File.stub(:exists?).with('/.chef/knife.rb').and_return(true)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'uses the top-level directory' do
|
74
|
+
expect(subject.path).to eq('/.chef/knife.rb')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'uses $HOME' do
|
80
|
+
ENV.stub(:[]).with('HOME').and_return(File.join(path, '..'))
|
81
|
+
expect(subject.path).to eq(config)
|
82
|
+
end
|
8
83
|
end
|
9
|
-
end
|
84
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berkshelf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.4.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jamie Winsor
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-
|
15
|
+
date: 2013-04-13 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: celluloid
|
@@ -229,7 +229,7 @@ dependencies:
|
|
229
229
|
requirements:
|
230
230
|
- - ~>
|
231
231
|
- !ruby/object:Gem::Version
|
232
|
-
version: 0.
|
232
|
+
version: 0.18.0
|
233
233
|
type: :runtime
|
234
234
|
prerelease: false
|
235
235
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -237,7 +237,7 @@ dependencies:
|
|
237
237
|
requirements:
|
238
238
|
- - ~>
|
239
239
|
- !ruby/object:Gem::Version
|
240
|
-
version: 0.
|
240
|
+
version: 0.18.0
|
241
241
|
- !ruby/object:Gem::Dependency
|
242
242
|
name: retryable
|
243
243
|
requirement: !ruby/object:Gem::Requirement
|
@@ -254,6 +254,22 @@ dependencies:
|
|
254
254
|
- - ! '>='
|
255
255
|
- !ruby/object:Gem::Version
|
256
256
|
version: '0'
|
257
|
+
- !ruby/object:Gem::Dependency
|
258
|
+
name: addressable
|
259
|
+
requirement: !ruby/object:Gem::Requirement
|
260
|
+
none: false
|
261
|
+
requirements:
|
262
|
+
- - ! '>='
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0'
|
265
|
+
type: :runtime
|
266
|
+
prerelease: false
|
267
|
+
version_requirements: !ruby/object:Gem::Requirement
|
268
|
+
none: false
|
269
|
+
requirements:
|
270
|
+
- - ! '>='
|
271
|
+
- !ruby/object:Gem::Version
|
272
|
+
version: '0'
|
257
273
|
- !ruby/object:Gem::Dependency
|
258
274
|
name: aruba
|
259
275
|
requirement: !ruby/object:Gem::Requirement
|
@@ -441,10 +457,12 @@ files:
|
|
441
457
|
- bin/berks
|
442
458
|
- features/config.feature
|
443
459
|
- features/configure_command.feature
|
460
|
+
- features/contingent_command.feature
|
444
461
|
- features/cookbook_command.feature
|
445
462
|
- features/default_locations.feature
|
446
463
|
- features/groups_install.feature
|
447
464
|
- features/help.feature
|
465
|
+
- features/info_command.feature
|
448
466
|
- features/init_command.feature
|
449
467
|
- features/install_command.feature
|
450
468
|
- features/json_formatter.feature
|
@@ -472,7 +490,9 @@ files:
|
|
472
490
|
- generator_files/Vagrantfile.erb
|
473
491
|
- generator_files/chefignore
|
474
492
|
- generator_files/default_recipe.erb
|
493
|
+
- generator_files/default_test.rb.erb
|
475
494
|
- generator_files/gitignore.erb
|
495
|
+
- generator_files/helpers.rb.erb
|
476
496
|
- generator_files/licenses/apachev2.erb
|
477
497
|
- generator_files/licenses/gplv2.erb
|
478
498
|
- generator_files/licenses/gplv3.erb
|
@@ -518,6 +538,7 @@ files:
|
|
518
538
|
- lib/berkshelf/mixin/logging.rb
|
519
539
|
- lib/berkshelf/mixin/path_helpers.rb
|
520
540
|
- lib/berkshelf/resolver.rb
|
541
|
+
- lib/berkshelf/test.rb
|
521
542
|
- lib/berkshelf/thor.rb
|
522
543
|
- lib/berkshelf/ui.rb
|
523
544
|
- lib/berkshelf/version.rb
|
@@ -612,22 +633,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
612
633
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
613
634
|
none: false
|
614
635
|
requirements:
|
615
|
-
- - ! '
|
636
|
+
- - ! '>='
|
616
637
|
- !ruby/object:Gem::Version
|
617
|
-
version:
|
638
|
+
version: '0'
|
639
|
+
segments:
|
640
|
+
- 0
|
641
|
+
hash: -3407693517536282074
|
618
642
|
requirements: []
|
619
643
|
rubyforge_project:
|
620
|
-
rubygems_version: 1.8.
|
644
|
+
rubygems_version: 1.8.23
|
621
645
|
signing_key:
|
622
646
|
specification_version: 3
|
623
647
|
summary: Manages a Cookbook's, or an Application's, Cookbook dependencies
|
624
648
|
test_files:
|
625
649
|
- features/config.feature
|
626
650
|
- features/configure_command.feature
|
651
|
+
- features/contingent_command.feature
|
627
652
|
- features/cookbook_command.feature
|
628
653
|
- features/default_locations.feature
|
629
654
|
- features/groups_install.feature
|
630
655
|
- features/help.feature
|
656
|
+
- features/info_command.feature
|
631
657
|
- features/init_command.feature
|
632
658
|
- features/install_command.feature
|
633
659
|
- features/json_formatter.feature
|