berkshelf 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/CHANGELOG.md +7 -0
  2. data/Gemfile +2 -0
  3. data/berkshelf.gemspec +5 -4
  4. data/features/berksfile.feature +56 -0
  5. data/features/install_command.feature +99 -13
  6. data/features/json_formatter.feature +1 -1
  7. data/features/lockfile.feature +50 -23
  8. data/features/step_definitions/filesystem_steps.rb +14 -1
  9. data/features/step_definitions/json_steps.rb +1 -1
  10. data/features/update_command.feature +2 -2
  11. data/features/upload_command.feature +0 -1
  12. data/lib/berkshelf.rb +1 -15
  13. data/lib/berkshelf/berksfile.rb +27 -21
  14. data/lib/berkshelf/cli.rb +2 -3
  15. data/lib/berkshelf/commands/test_command.rb +4 -2
  16. data/lib/berkshelf/community_rest.rb +6 -0
  17. data/lib/berkshelf/cookbook_source.rb +15 -37
  18. data/lib/berkshelf/core_ext/rbzip2.rb +8 -0
  19. data/lib/berkshelf/downloader.rb +56 -47
  20. data/lib/berkshelf/errors.rb +9 -2
  21. data/lib/berkshelf/formatters/human_readable.rb +10 -3
  22. data/lib/berkshelf/formatters/json.rb +7 -3
  23. data/lib/berkshelf/git.rb +2 -1
  24. data/lib/berkshelf/init_generator.rb +18 -12
  25. data/lib/berkshelf/location.rb +4 -14
  26. data/lib/berkshelf/locations/chef_api_location.rb +0 -1
  27. data/lib/berkshelf/locations/git_location.rb +1 -2
  28. data/lib/berkshelf/locations/path_location.rb +35 -11
  29. data/lib/berkshelf/locations/site_location.rb +0 -1
  30. data/lib/berkshelf/resolver.rb +18 -14
  31. data/lib/berkshelf/version.rb +1 -1
  32. data/spec/fixtures/cookbooks/example_cookbook/Berksfile +1 -0
  33. data/spec/unit/berkshelf/berksfile_spec.rb +30 -2
  34. data/spec/unit/berkshelf/community_rest_spec.rb +49 -11
  35. data/spec/unit/berkshelf/cookbook_source_spec.rb +11 -7
  36. data/spec/unit/berkshelf/downloader_spec.rb +1 -1
  37. data/spec/unit/berkshelf/location_spec.rb +0 -6
  38. data/spec/unit/berkshelf/locations/chef_api_location_spec.rb +0 -4
  39. data/spec/unit/berkshelf/locations/git_location_spec.rb +0 -5
  40. data/spec/unit/berkshelf/locations/path_location_spec.rb +0 -41
  41. data/spec/unit/berkshelf_spec.rb +0 -25
  42. metadata +37 -16
@@ -233,7 +233,8 @@ describe Berkshelf::CookbookSource do
233
233
  it 'returns a PathLocation with a path relative to the Berksfile.filepath' do
234
234
  _, location = subject.cached_and_location(options)
235
235
 
236
- expect(location.path).to eq('/rspec/cookbooks/whatever')
236
+ expect(location.path).to eq('cookbooks/whatever')
237
+ expect(location.relative_path(berksfile)).to eq('../cookbooks/whatever')
237
238
  end
238
239
  end
239
240
  end
@@ -275,8 +276,8 @@ describe Berkshelf::CookbookSource do
275
276
 
276
277
  it 'does not include the site if it is the default' do
277
278
  location = double('site', api_uri: Berkshelf::CommunityREST::V1_API)
279
+ location.stub(:kind_of?).and_return(false)
278
280
  location.stub(:kind_of?).with(Berkshelf::SiteLocation).and_return(true)
279
- location.stub(:kind_of?).with(Berkshelf::GitLocation).and_return(false)
280
281
  subject.stub(:location).and_return(location)
281
282
 
282
283
  expect(hash).to_not have_key(:site)
@@ -284,8 +285,8 @@ describe Berkshelf::CookbookSource do
284
285
 
285
286
  it 'includes the site' do
286
287
  location = double('site', api_uri: 'www.example.com')
288
+ location.stub(:kind_of?).and_return(false)
287
289
  location.stub(:kind_of?).with(Berkshelf::SiteLocation).and_return(true)
288
- location.stub(:kind_of?).with(Berkshelf::GitLocation).and_return(false)
289
290
  subject.stub(:location).and_return(location)
290
291
 
291
292
  expect(hash).to have_key(:site)
@@ -294,7 +295,7 @@ describe Berkshelf::CookbookSource do
294
295
 
295
296
  it 'includes the git url and ref' do
296
297
  location = double('git', uri: 'git://github.com/foo/bar.git', ref: 'abcd1234', rel: nil)
297
- location.stub(:kind_of?).with(Berkshelf::SiteLocation).and_return(false)
298
+ location.stub(:kind_of?).and_return(false)
298
299
  location.stub(:kind_of?).with(Berkshelf::GitLocation).and_return(true)
299
300
  subject.stub(:location).and_return(location)
300
301
 
@@ -306,7 +307,7 @@ describe Berkshelf::CookbookSource do
306
307
 
307
308
  it 'includes the git url and rel' do
308
309
  location = double('git', uri: 'git://github.com/foo/bar.git', ref: nil, rel: 'cookbooks/foo')
309
- location.stub(:kind_of?).with(Berkshelf::SiteLocation).and_return(false)
310
+ location.stub(:kind_of?).and_return(false)
310
311
  location.stub(:kind_of?).with(Berkshelf::GitLocation).and_return(true)
311
312
  subject.stub(:location).and_return(location)
312
313
 
@@ -317,10 +318,13 @@ describe Berkshelf::CookbookSource do
317
318
  end
318
319
 
319
320
  it 'includes a relative path' do
320
- subject.instance_variable_set(:@options, { path: '~/Development/foo' })
321
+ location = double('path', relative_path: '../dev/foo')
322
+ location.stub(:kind_of?).and_return(false)
323
+ location.stub(:kind_of?).with(Berkshelf::PathLocation).and_return(true)
324
+ subject.stub(:location).and_return(location)
321
325
 
322
326
  expect(hash).to have_key(:path)
323
- expect(hash[:path]).to eq('~/Development/foo')
327
+ expect(hash[:path]).to eq('../dev/foo')
324
328
  end
325
329
  end
326
330
 
@@ -41,7 +41,7 @@ describe Berkshelf::Downloader do
41
41
  subject { Berkshelf::Downloader.new(cookbook_store) }
42
42
 
43
43
  describe '#download' do
44
- let(:source) { double('source', name: 'artifact', version_constraint: '= 0.10.0') }
44
+ let(:source) { double('source', name: 'artifact', version_constraint: '= 0.10.0', locked_version: '0.10.0') }
45
45
  let(:location) { double('location') }
46
46
  let(:cached_cookbook) { double('cached') }
47
47
 
@@ -140,12 +140,6 @@ describe Berkshelf::Location do
140
140
  Class.new { include Berkshelf::Location }.new(name, constraint)
141
141
  end
142
142
 
143
- describe 'downloaded?' do
144
- it 'starts as false' do
145
- expect(subject.downloaded?).to be_false
146
- end
147
- end
148
-
149
143
  describe '#download' do
150
144
  it 'raises a AbstractFunction if not defined' do
151
145
  expect {
@@ -31,10 +31,6 @@ describe Berkshelf::ChefAPILocation, :chef_server do
31
31
  expect(subject.client_key).to eq(client_key)
32
32
  end
33
33
 
34
- it 'sets the downloaded status to false' do
35
- expect(subject).to_not be_downloaded
36
- end
37
-
38
34
  context 'when an invalid Chef API URI is given' do
39
35
  it 'raises Berkshelf::InvalidChefAPILocation' do
40
36
  expect {
@@ -52,11 +52,6 @@ describe Berkshelf::GitLocation do
52
52
  }
53
53
  end
54
54
 
55
- it 'sets the downloaded status to true' do
56
- subject.download(tmp_path)
57
- expect(subject).to be_downloaded
58
- end
59
-
60
55
  context 'given no ref/branch/tag options is given' do
61
56
  subject { Berkshelf::GitLocation.new('berkshelf-cookbook-fixture', complacent_constraint, git: 'git://github.com/RiotGames/berkshelf-cookbook-fixture.git') }
62
57
 
@@ -15,47 +15,6 @@ describe Berkshelf::PathLocation do
15
15
 
16
16
  subject { Berkshelf::PathLocation.new('nginx', complacent_constraint, path: path) }
17
17
 
18
- describe '#download' do
19
- it 'returns an instance of CachedCookbook' do
20
- expect(subject.download(tmp_path)).to be_a(Berkshelf::CachedCookbook)
21
- end
22
-
23
- it 'sets the downloaded status to true' do
24
- subject.download(tmp_path)
25
- expect(subject).to be_downloaded
26
- end
27
-
28
- context 'given a path that does not exist' do
29
- subject { Berkshelf::PathLocation.new('doesnot_exist', complacent_constraint, path: tmp_path.join('doesntexist_noway')) }
30
-
31
- it 'raises a CookbookNotFound error' do
32
- expect {
33
- subject.download(tmp_path)
34
- }.to raise_error(Berkshelf::CookbookNotFound)
35
- end
36
- end
37
-
38
- context 'given a path that does not contain a cookbook' do
39
- subject { Berkshelf::PathLocation.new('doesnot_exist', complacent_constraint, path: fixtures_path) }
40
-
41
- it 'raises a CookbookNotFound error' do
42
- expect {
43
- subject.download(tmp_path)
44
- }.to raise_error(Berkshelf::CookbookNotFound)
45
- end
46
- end
47
-
48
- context 'given the content at path does not satisfy the version constraint' do
49
- subject { Berkshelf::PathLocation.new('nginx', double('constraint', satisfies?: false), path: path) }
50
-
51
- it 'raises a CookbookValidationFailure error' do
52
- expect {
53
- subject.download(double('path'))
54
- }.to raise_error(Berkshelf::CookbookValidationFailure)
55
- end
56
- end
57
- end
58
-
59
18
  describe '#to_s' do
60
19
  context 'for a remote path' do
61
20
  subject { Berkshelf::PathLocation.new('nginx', complacent_constraint, path: path) }
@@ -1,31 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Berkshelf do
4
- describe '.find_metadata' do
5
- let(:metadata_path) { fixtures_path.join('cookbooks', 'example_cookbook', 'metadata.rb') }
6
-
7
- context 'given a path containing a metadata.rb file' do
8
- it 'returns the path to the metadata.rb file' do
9
- metadata = Berkshelf.find_metadata(fixtures_path.join('cookbooks', 'example_cookbook'))
10
- expect(metadata).to eq(metadata_path)
11
- end
12
- end
13
-
14
- context 'given a path where a parent path contains a metadata.rb file' do
15
- it 'returns the path to the metadata.rb file' do
16
- metadata = Berkshelf.find_metadata(fixtures_path.join('cookbooks', 'example_cookbook', 'recipes'))
17
- expect(metadata).to eq(metadata_path)
18
- end
19
- end
20
-
21
- context 'given a path that does not contain a metadata.rb file or a parent path that does' do
22
- it 'returns nil' do
23
- metadata = Berkshelf.find_metadata(tmp_path)
24
- expect(metadata).to be_nil
25
- end
26
- end
27
- end
28
-
29
4
  describe '.formatter' do
30
5
  context 'with default formatter' do
31
6
  before { Berkshelf.instance_variable_set(:@formatter, nil) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkshelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-06-11 00:00:00.000000000 Z
16
+ date: 2013-06-17 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activesupport
@@ -47,6 +47,22 @@ dependencies:
47
47
  - - ~>
48
48
  - !ruby/object:Gem::Version
49
49
  version: 2.3.4
50
+ - !ruby/object:Gem::Dependency
51
+ name: buff-shell_out
52
+ requirement: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: '0.1'
58
+ type: :runtime
59
+ prerelease: false
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '0.1'
50
66
  - !ruby/object:Gem::Dependency
51
67
  name: celluloid
52
68
  requirement: !ruby/object:Gem::Requirement
@@ -150,7 +166,7 @@ dependencies:
150
166
  requirements:
151
167
  - - ~>
152
168
  - !ruby/object:Gem::Version
153
- version: 1.0.2
169
+ version: 1.2.1
154
170
  type: :runtime
155
171
  prerelease: false
156
172
  version_requirements: !ruby/object:Gem::Requirement
@@ -158,7 +174,7 @@ dependencies:
158
174
  requirements:
159
175
  - - ~>
160
176
  - !ruby/object:Gem::Version
161
- version: 1.0.2
177
+ version: 1.2.1
162
178
  - !ruby/object:Gem::Dependency
163
179
  name: solve
164
180
  requirement: !ruby/object:Gem::Requirement
@@ -166,7 +182,7 @@ dependencies:
166
182
  requirements:
167
183
  - - ! '>='
168
184
  - !ruby/object:Gem::Version
169
- version: 0.4.4
185
+ version: 0.5.0
170
186
  type: :runtime
171
187
  prerelease: false
172
188
  version_requirements: !ruby/object:Gem::Requirement
@@ -174,31 +190,31 @@ dependencies:
174
190
  requirements:
175
191
  - - ! '>='
176
192
  - !ruby/object:Gem::Version
177
- version: 0.4.4
193
+ version: 0.5.0
178
194
  - !ruby/object:Gem::Dependency
179
- name: test-kitchen
195
+ name: thor
180
196
  requirement: !ruby/object:Gem::Requirement
181
197
  none: false
182
198
  requirements:
183
- - - ! '>='
199
+ - - ~>
184
200
  - !ruby/object:Gem::Version
185
- version: 1.0.0.alpha7
201
+ version: 0.18.0
186
202
  type: :runtime
187
203
  prerelease: false
188
204
  version_requirements: !ruby/object:Gem::Requirement
189
205
  none: false
190
206
  requirements:
191
- - - ! '>='
207
+ - - ~>
192
208
  - !ruby/object:Gem::Version
193
- version: 1.0.0.alpha7
209
+ version: 0.18.0
194
210
  - !ruby/object:Gem::Dependency
195
- name: thor
211
+ name: rbzip2
196
212
  requirement: !ruby/object:Gem::Requirement
197
213
  none: false
198
214
  requirements:
199
215
  - - ~>
200
216
  - !ruby/object:Gem::Version
201
- version: 0.18.0
217
+ version: 0.2.0
202
218
  type: :runtime
203
219
  prerelease: false
204
220
  version_requirements: !ruby/object:Gem::Requirement
@@ -206,7 +222,7 @@ dependencies:
206
222
  requirements:
207
223
  - - ~>
208
224
  - !ruby/object:Gem::Version
209
- version: 0.18.0
225
+ version: 0.2.0
210
226
  - !ruby/object:Gem::Dependency
211
227
  name: aruba
212
228
  requirement: !ruby/object:Gem::Requirement
@@ -246,7 +262,7 @@ dependencies:
246
262
  requirements:
247
263
  - - ~>
248
264
  - !ruby/object:Gem::Version
249
- version: '1.1'
265
+ version: 1.5.0
250
266
  type: :development
251
267
  prerelease: false
252
268
  version_requirements: !ruby/object:Gem::Requirement
@@ -254,7 +270,7 @@ dependencies:
254
270
  requirements:
255
271
  - - ~>
256
272
  - !ruby/object:Gem::Version
257
- version: '1.1'
273
+ version: 1.5.0
258
274
  - !ruby/object:Gem::Dependency
259
275
  name: fuubar
260
276
  requirement: !ruby/object:Gem::Requirement
@@ -523,6 +539,7 @@ files:
523
539
  - berkshelf.gemspec
524
540
  - bin/berks
525
541
  - features/apply_command.feature
542
+ - features/berksfile.feature
526
543
  - features/config.feature
527
544
  - features/configure_command.feature
528
545
  - features/contingent_command.feature
@@ -590,6 +607,7 @@ files:
590
607
  - lib/berkshelf/core_ext/file.rb
591
608
  - lib/berkshelf/core_ext/file_utils.rb
592
609
  - lib/berkshelf/core_ext/pathname.rb
610
+ - lib/berkshelf/core_ext/rbzip2.rb
593
611
  - lib/berkshelf/core_ext/string.rb
594
612
  - lib/berkshelf/downloader.rb
595
613
  - lib/berkshelf/errors.rb
@@ -641,6 +659,7 @@ files:
641
659
  - spec/fixtures/cookbooks/example_cookbook-0.5.0/recipes/default.rb
642
660
  - spec/fixtures/cookbooks/example_cookbook/.gitignore
643
661
  - spec/fixtures/cookbooks/example_cookbook/.kitchen.yml
662
+ - spec/fixtures/cookbooks/example_cookbook/Berksfile
644
663
  - spec/fixtures/cookbooks/example_cookbook/Berksfile.lock
645
664
  - spec/fixtures/cookbooks/example_cookbook/README.md
646
665
  - spec/fixtures/cookbooks/example_cookbook/metadata.rb
@@ -726,6 +745,7 @@ specification_version: 3
726
745
  summary: Manages a Cookbook's, or an Application's, Cookbook dependencies
727
746
  test_files:
728
747
  - features/apply_command.feature
748
+ - features/berksfile.feature
729
749
  - features/config.feature
730
750
  - features/configure_command.feature
731
751
  - features/contingent_command.feature
@@ -779,6 +799,7 @@ test_files:
779
799
  - spec/fixtures/cookbooks/example_cookbook-0.5.0/recipes/default.rb
780
800
  - spec/fixtures/cookbooks/example_cookbook/.gitignore
781
801
  - spec/fixtures/cookbooks/example_cookbook/.kitchen.yml
802
+ - spec/fixtures/cookbooks/example_cookbook/Berksfile
782
803
  - spec/fixtures/cookbooks/example_cookbook/Berksfile.lock
783
804
  - spec/fixtures/cookbooks/example_cookbook/README.md
784
805
  - spec/fixtures/cookbooks/example_cookbook/metadata.rb