berkshelf 0.3.7 → 0.4.0.rc1

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.
Files changed (44) hide show
  1. data/.gitignore +2 -1
  2. data/README.md +8 -0
  3. data/Thorfile +2 -2
  4. data/berkshelf.gemspec +1 -1
  5. data/features/install.feature +102 -2
  6. data/features/lockfile.feature +1 -1
  7. data/features/step_definitions/chef_server_steps.rb +8 -0
  8. data/features/step_definitions/cli_steps.rb +1 -1
  9. data/features/step_definitions/filesystem_steps.rb +12 -0
  10. data/features/support/env.rb +8 -10
  11. data/features/update.feature +1 -1
  12. data/lib/berkshelf.rb +19 -1
  13. data/lib/berkshelf/berksfile.rb +18 -6
  14. data/lib/berkshelf/cli.rb +3 -8
  15. data/lib/berkshelf/cookbook_source.rb +108 -23
  16. data/lib/berkshelf/cookbook_source/chef_api_location.rb +256 -0
  17. data/lib/berkshelf/cookbook_source/git_location.rb +14 -2
  18. data/lib/berkshelf/cookbook_source/location.rb +119 -2
  19. data/lib/berkshelf/cookbook_source/path_location.rb +6 -1
  20. data/lib/berkshelf/cookbook_source/site_location.rb +36 -105
  21. data/lib/berkshelf/cookbook_store.rb +7 -12
  22. data/lib/berkshelf/dsl.rb +1 -1
  23. data/lib/berkshelf/errors.rb +2 -0
  24. data/lib/berkshelf/init_generator.rb +6 -6
  25. data/lib/berkshelf/resolver.rb +8 -34
  26. data/lib/berkshelf/uploader.rb +7 -7
  27. data/lib/berkshelf/version.rb +1 -1
  28. data/spec/fixtures/reset.pem +27 -0
  29. data/spec/knife.rb.sample +12 -0
  30. data/spec/spec_helper.rb +4 -1
  31. data/spec/support/chef_api.rb +32 -0
  32. data/spec/support/knife.rb +18 -0
  33. data/spec/unit/berkshelf/cookbook_source/chef_api_location_spec.rb +243 -0
  34. data/spec/unit/berkshelf/cookbook_source/git_location_spec.rb +2 -2
  35. data/spec/unit/berkshelf/cookbook_source/location_spec.rb +130 -2
  36. data/spec/unit/berkshelf/cookbook_source/path_location_spec.rb +2 -2
  37. data/spec/unit/berkshelf/cookbook_source/site_location_spec.rb +22 -105
  38. data/spec/unit/berkshelf/cookbook_source_spec.rb +140 -71
  39. data/spec/unit/berkshelf/cookbook_store_spec.rb +6 -6
  40. data/spec/unit/berkshelf/resolver_spec.rb +9 -30
  41. data/spec/unit/berkshelf/uploader_spec.rb +1 -10
  42. data/spec/unit/berkshelf_spec.rb +21 -1
  43. metadata +19 -15
  44. data/features/config.sample.yml +0 -3
@@ -36,10 +36,10 @@ module Berkshelf
36
36
 
37
37
  describe "#satisfy" do
38
38
  let(:name) { "nginx" }
39
- let(:version) { DepSelector::Version.new("0.101.4") }
40
- let(:constraint) { DepSelector::VersionConstraint.new("~> 0.101.2") }
41
- let(:cached_cb) { double('cached-cb', name: name, version: version) }
42
- let(:cached_two) { double('cached-two', name: "mysql", version: DepSelector::Version.new("1.2.6")) }
39
+ let(:version) { "0.101.4" }
40
+ let(:constraint) { Solve::Constraint.new("~> 0.101.2") }
41
+ let(:cached_cb) { double('cached-cb', name: name, version: Solve::Version.new(version)) }
42
+ let(:cached_two) { double('cached-two', name: "mysql", version: Solve::Version.new("1.2.6")) }
43
43
 
44
44
  before(:each) do
45
45
  subject.stub(:cookbooks).and_return([cached_cb, cached_two])
@@ -60,8 +60,8 @@ module Berkshelf
60
60
  end
61
61
 
62
62
  context "when there is no matching cookbook for the given name and constraint" do
63
- let(:version) { DepSelector::Version.new("1.0.0") }
64
- let(:constraint) { DepSelector::VersionConstraint.new("= 0.0.1") }
63
+ let(:version) { Solve::Version.new("1.0.0") }
64
+ let(:constraint) { Solve::Constraint.new("= 0.0.1") }
65
65
 
66
66
  before(:each) do
67
67
  subject.stub(:cookbooks).and_return([ double('badcache', name: 'none', version: version) ])
@@ -5,7 +5,7 @@ module Berkshelf
5
5
  let(:source) do
6
6
  double('source',
7
7
  name: 'mysql',
8
- version_constraint: DepSelector::VersionConstraint.new('= 1.2.4'),
8
+ version_constraint: Solve::Constraint.new('= 1.2.4'),
9
9
  downloaded?: true,
10
10
  cached_cookbook: double('mysql-cookbook',
11
11
  name: 'mysql-1.2.4',
@@ -20,7 +20,7 @@ module Berkshelf
20
20
  let(:source_two) do
21
21
  double('source-two',
22
22
  name: 'nginx',
23
- version_constraint: DepSelector::VersionConstraint.new('= 0.101.2'),
23
+ version_constraint: Solve::Constraint.new('= 0.101.2'),
24
24
  downloaded?: true,
25
25
  cached_cookbook: double('nginx-cookbook',
26
26
  name: 'nginx-0.101.2',
@@ -46,18 +46,9 @@ module Berkshelf
46
46
 
47
47
  it "adds the dependencies of the source as sources" do
48
48
  resolver = subject.new(downloader, source)
49
-
50
- source.cached_cookbook.dependencies.each do |name, constraint|
51
- resolver.package(name).should_not be_nil
52
- end
53
- end
54
-
55
- it "adds the version_constraints of the dependencies to the graph" do
56
- resolver = subject.new(downloader, source)
57
-
58
- source.cached_cookbook.dependencies.each do |name, constraint|
59
- resolver.package(name).versions.should_not be_empty
60
- end
49
+
50
+ resolver.should have_source("nginx")
51
+ resolver.should have_source("artifact")
61
52
  end
62
53
 
63
54
  context "given an array of sources" do
@@ -82,14 +73,10 @@ module Berkshelf
82
73
  subject.sources.should include(source)
83
74
  end
84
75
 
85
- it "adds a package of the same name of the source to the graph" do
86
- subject.package(source.name).should_not be_nil
87
- end
88
-
89
- it "adds a version constraint specified by the source to the package of the same name" do
90
- subject.add_source(source)
91
-
92
- subject.package(source.name).versions.collect(&:version).should include(source.version_constraint.version)
76
+ it "adds an artifact of the same name of the source to the graph" do
77
+ subject.graph.should_receive(:artifacts).with(source.name, source.cached_cookbook.version)
78
+
79
+ subject.add_source(source, false)
93
80
  end
94
81
 
95
82
  it "adds the dependencies of the source as packages to the graph" do
@@ -106,14 +93,6 @@ module Berkshelf
106
93
  }.should raise_error(DuplicateSourceDefined)
107
94
  end
108
95
 
109
- it "adds a package for each dependency to the packages attribute" do
110
- subject.add_source(source)
111
-
112
- source.cached_cookbook.dependencies.each do |name, constraint|
113
- subject.package(name).should_not be_nil
114
- end
115
- end
116
-
117
96
  context "when include_dependencies is false" do
118
97
  it "does not try to include_dependencies" do
119
98
  subject.should_not_receive(:add_source_dependencies)
@@ -2,16 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module Berkshelf
4
4
  describe Uploader do
5
-
6
- unless config = YAML.load_file('features/config.yml')
7
- raise "Could not load features/config.yml -- please generate it from features/config.sample.yml"
8
- end
9
-
10
- let(:server_url) { config["chef_server_url"] }
11
- let(:client_key) { config["client_key"] }
12
- let(:node_name) { config["node_name"] }
13
-
14
- subject { Uploader.new(server_url, client_key: client_key, node_name: node_name) }
5
+ subject { Uploader.new(Chef::Config[:chef_server_url], client_key: Chef::Config[:client_key], node_name: Chef::Config[:node_name]) }
15
6
 
16
7
  describe "#upload" do
17
8
  let(:cookbook) { double('nginx', name: "nginx-0.101.2", cookbook_name: "nginx", version: "0.101.2") }
@@ -4,7 +4,7 @@ describe Berkshelf do
4
4
  context "ClassMethods" do
5
5
  subject { Berkshelf }
6
6
 
7
- describe "#find_metadata" do
7
+ describe "::find_metadata" do
8
8
  let(:metadata_path) { fixtures_path.join("cookbooks", "example_cookbook", "metadata.rb") }
9
9
 
10
10
  context "given a path containing a metadata.rb file" do
@@ -25,5 +25,25 @@ describe Berkshelf do
25
25
  end
26
26
  end
27
27
  end
28
+
29
+ describe "::config_path" do
30
+ it "returns a default value if nothing is specified" do
31
+ subject.config_path.should eql(Berkshelf::DEFAULT_CONFIG)
32
+ end
33
+
34
+ it "returns the value assigned if specified" do
35
+ subject.config_path = value = "/Users/reset/.chef/knife.rb"
36
+
37
+ subject.config_path.should eql(value)
38
+ end
39
+ end
40
+
41
+ describe "::load_config" do
42
+ it "loads the path specified by config_path if no parameter given" do
43
+ Chef::Config.should_receive(:from_file).with(Berkshelf.config_path)
44
+
45
+ subject.load_config
46
+ end
47
+ end
28
48
  end
29
49
  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: 0.3.7
5
- prerelease:
4
+ version: 0.4.0.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Josiah Kiehl
@@ -12,24 +12,24 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-07-04 00:00:00.000000000 Z
15
+ date: 2012-07-13 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
- name: dep_selector
18
+ name: solve
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
- - - ! '>='
22
+ - - ~>
23
23
  - !ruby/object:Gem::Version
24
- version: '0'
24
+ version: 0.2.1
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ! '>='
30
+ - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
32
+ version: 0.2.1
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: chef
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -370,7 +370,6 @@ files:
370
370
  - Thorfile
371
371
  - berkshelf.gemspec
372
372
  - bin/berks
373
- - features/config.sample.yml
374
373
  - features/init_command.feature
375
374
  - features/install.feature
376
375
  - features/lockfile.feature
@@ -387,6 +386,7 @@ files:
387
386
  - lib/berkshelf/cached_cookbook.rb
388
387
  - lib/berkshelf/cli.rb
389
388
  - lib/berkshelf/cookbook_source.rb
389
+ - lib/berkshelf/cookbook_source/chef_api_location.rb
390
390
  - lib/berkshelf/cookbook_source/git_location.rb
391
391
  - lib/berkshelf/cookbook_source/location.rb
392
392
  - lib/berkshelf/cookbook_source/path_location.rb
@@ -436,12 +436,16 @@ files:
436
436
  - spec/fixtures/cookbooks/nginx-0.100.5/templates/default/plugins/nginx.rb.erb
437
437
  - spec/fixtures/lockfile_spec/with_lock/Berksfile
438
438
  - spec/fixtures/lockfile_spec/without_lock/Berksfile.lock
439
+ - spec/fixtures/reset.pem
440
+ - spec/knife.rb.sample
439
441
  - spec/spec_helper.rb
440
442
  - spec/support/chef_api.rb
443
+ - spec/support/knife.rb
441
444
  - spec/support/matchers/file_system_matchers.rb
442
445
  - spec/support/matchers/filepath_matchers.rb
443
446
  - spec/unit/berkshelf/berksfile_spec.rb
444
447
  - spec/unit/berkshelf/cached_cookbook_spec.rb
448
+ - spec/unit/berkshelf/cookbook_source/chef_api_location_spec.rb
445
449
  - spec/unit/berkshelf/cookbook_source/git_location_spec.rb
446
450
  - spec/unit/berkshelf/cookbook_source/location_spec.rb
447
451
  - spec/unit/berkshelf/cookbook_source/path_location_spec.rb
@@ -473,12 +477,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
473
477
  required_rubygems_version: !ruby/object:Gem::Requirement
474
478
  none: false
475
479
  requirements:
476
- - - ! '>='
480
+ - - ! '>'
477
481
  - !ruby/object:Gem::Version
478
- version: '0'
479
- segments:
480
- - 0
481
- hash: -4298839394573709666
482
+ version: 1.3.1
482
483
  requirements: []
483
484
  rubyforge_project:
484
485
  rubygems_version: 1.8.23
@@ -486,7 +487,6 @@ signing_key:
486
487
  specification_version: 3
487
488
  summary: Manages a Cookbook's, or an Application's, Cookbook dependencies
488
489
  test_files:
489
- - features/config.sample.yml
490
490
  - features/init_command.feature
491
491
  - features/install.feature
492
492
  - features/lockfile.feature
@@ -522,12 +522,16 @@ test_files:
522
522
  - spec/fixtures/cookbooks/nginx-0.100.5/templates/default/plugins/nginx.rb.erb
523
523
  - spec/fixtures/lockfile_spec/with_lock/Berksfile
524
524
  - spec/fixtures/lockfile_spec/without_lock/Berksfile.lock
525
+ - spec/fixtures/reset.pem
526
+ - spec/knife.rb.sample
525
527
  - spec/spec_helper.rb
526
528
  - spec/support/chef_api.rb
529
+ - spec/support/knife.rb
527
530
  - spec/support/matchers/file_system_matchers.rb
528
531
  - spec/support/matchers/filepath_matchers.rb
529
532
  - spec/unit/berkshelf/berksfile_spec.rb
530
533
  - spec/unit/berkshelf/cached_cookbook_spec.rb
534
+ - spec/unit/berkshelf/cookbook_source/chef_api_location_spec.rb
531
535
  - spec/unit/berkshelf/cookbook_source/git_location_spec.rb
532
536
  - spec/unit/berkshelf/cookbook_source/location_spec.rb
533
537
  - spec/unit/berkshelf/cookbook_source/path_location_spec.rb
@@ -1,3 +0,0 @@
1
- node_name: 'reset'
2
- client_key: '/Users/reset/.chef/reset.pem'
3
- chef_server_url: 'https://api.opscode.com/organizations/vialstudios'