berkshelf 5.5.0 → 5.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -3
  3. data/Gemfile +31 -31
  4. data/Gemfile.lock +3 -3
  5. data/Guardfile +13 -13
  6. data/Rakefile +1 -0
  7. data/Thorfile +16 -16
  8. data/berkshelf.gemspec +35 -35
  9. data/features/step_definitions/chef/config_steps.rb +4 -4
  10. data/features/step_definitions/chef_server_steps.rb +6 -6
  11. data/features/step_definitions/cli_steps.rb +3 -3
  12. data/features/step_definitions/config_steps.rb +5 -5
  13. data/features/step_definitions/filesystem_steps.rb +12 -11
  14. data/features/support/env.rb +21 -21
  15. data/lib/berkshelf.rb +66 -66
  16. data/lib/berkshelf/base_generator.rb +10 -11
  17. data/lib/berkshelf/berksfile.rb +38 -38
  18. data/lib/berkshelf/cached_cookbook.rb +7 -7
  19. data/lib/berkshelf/cli.rb +126 -126
  20. data/lib/berkshelf/commands/shelf.rb +19 -18
  21. data/lib/berkshelf/commands/test_command.rb +2 -2
  22. data/lib/berkshelf/community_rest.rb +38 -38
  23. data/lib/berkshelf/config.rb +42 -41
  24. data/lib/berkshelf/cookbook_generator.rb +38 -38
  25. data/lib/berkshelf/cookbook_store.rb +4 -4
  26. data/lib/berkshelf/core_ext/file_utils.rb +1 -1
  27. data/lib/berkshelf/dependency.rb +23 -21
  28. data/lib/berkshelf/downloader.rb +24 -25
  29. data/lib/berkshelf/errors.rb +17 -17
  30. data/lib/berkshelf/file_syncer.rb +9 -8
  31. data/lib/berkshelf/formatters/human.rb +3 -3
  32. data/lib/berkshelf/formatters/json.rb +2 -2
  33. data/lib/berkshelf/init_generator.rb +64 -64
  34. data/lib/berkshelf/installer.rb +103 -102
  35. data/lib/berkshelf/location.rb +9 -9
  36. data/lib/berkshelf/locations/git.rb +16 -16
  37. data/lib/berkshelf/locations/github.rb +1 -1
  38. data/lib/berkshelf/locations/path.rb +2 -2
  39. data/lib/berkshelf/lockfile.rb +309 -315
  40. data/lib/berkshelf/mixin/git.rb +3 -3
  41. data/lib/berkshelf/packager.rb +4 -4
  42. data/lib/berkshelf/resolver.rb +2 -2
  43. data/lib/berkshelf/resolver/graph.rb +1 -1
  44. data/lib/berkshelf/shell.rb +1 -1
  45. data/lib/berkshelf/source.rb +6 -6
  46. data/lib/berkshelf/source_uri.rb +2 -2
  47. data/lib/berkshelf/ssl_policies.rb +3 -3
  48. data/lib/berkshelf/thor.rb +1 -1
  49. data/lib/berkshelf/uploader.rb +48 -48
  50. data/lib/berkshelf/validator.rb +2 -2
  51. data/lib/berkshelf/version.rb +1 -1
  52. data/lib/berkshelf/visualizer.rb +11 -11
  53. data/spec/config/knife.rb +2 -2
  54. data/spec/fixtures/Berksfile +3 -3
  55. data/spec/fixtures/cookbook-path/jenkins-config/metadata.rb +3 -3
  56. data/spec/fixtures/cookbook-store/jenkins-2.0.3/metadata.rb +5 -5
  57. data/spec/fixtures/cookbook-store/jenkins-2.0.4/metadata.rb +4 -4
  58. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +3 -3
  59. data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +3 -3
  60. data/spec/spec_helper.rb +9 -9
  61. data/spec/support/chef_api.rb +11 -12
  62. data/spec/support/chef_server.rb +10 -10
  63. data/spec/support/git.rb +23 -23
  64. data/spec/support/kitchen.rb +2 -2
  65. data/spec/support/matchers/filepath_matchers.rb +2 -2
  66. data/spec/support/path_helpers.rb +12 -12
  67. data/spec/support/shared_examples/formatter.rb +1 -1
  68. data/spec/unit/berkshelf/berksfile_spec.rb +78 -78
  69. data/spec/unit/berkshelf/cached_cookbook_spec.rb +42 -42
  70. data/spec/unit/berkshelf/cli_spec.rb +6 -6
  71. data/spec/unit/berkshelf/community_rest_spec.rb +83 -83
  72. data/spec/unit/berkshelf/config_spec.rb +13 -13
  73. data/spec/unit/berkshelf/cookbook_generator_spec.rb +39 -39
  74. data/spec/unit/berkshelf/cookbook_store_spec.rb +41 -41
  75. data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +5 -6
  76. data/spec/unit/berkshelf/core_ext/pathname_spec.rb +1 -1
  77. data/spec/unit/berkshelf/dependency_spec.rb +43 -43
  78. data/spec/unit/berkshelf/downloader_spec.rb +20 -20
  79. data/spec/unit/berkshelf/errors_spec.rb +3 -3
  80. data/spec/unit/berkshelf/file_syncer_spec.rb +86 -86
  81. data/spec/unit/berkshelf/formatters/base_spec.rb +23 -23
  82. data/spec/unit/berkshelf/formatters/human_spec.rb +2 -2
  83. data/spec/unit/berkshelf/formatters/json_spec.rb +2 -2
  84. data/spec/unit/berkshelf/formatters/null_spec.rb +3 -3
  85. data/spec/unit/berkshelf/init_generator_spec.rb +92 -92
  86. data/spec/unit/berkshelf/installer_spec.rb +8 -8
  87. data/spec/unit/berkshelf/location_spec.rb +11 -11
  88. data/spec/unit/berkshelf/locations/base_spec.rb +35 -35
  89. data/spec/unit/berkshelf/locations/git_spec.rb +87 -87
  90. data/spec/unit/berkshelf/locations/path_spec.rb +40 -40
  91. data/spec/unit/berkshelf/lockfile_parser_spec.rb +71 -71
  92. data/spec/unit/berkshelf/lockfile_spec.rb +197 -197
  93. data/spec/unit/berkshelf/logger_spec.rb +3 -3
  94. data/spec/unit/berkshelf/mixin/logging_spec.rb +5 -5
  95. data/spec/unit/berkshelf/packager_spec.rb +2 -2
  96. data/spec/unit/berkshelf/resolver/graph_spec.rb +1 -1
  97. data/spec/unit/berkshelf/resolver_spec.rb +17 -17
  98. data/spec/unit/berkshelf/shell_spec.rb +34 -34
  99. data/spec/unit/berkshelf/source_spec.rb +12 -11
  100. data/spec/unit/berkshelf/source_uri_spec.rb +1 -1
  101. data/spec/unit/berkshelf/ssl_policies_spec.rb +25 -25
  102. data/spec/unit/berkshelf/uploader_spec.rb +54 -54
  103. data/spec/unit/berkshelf/validator_spec.rb +16 -16
  104. data/spec/unit/berkshelf/visualizer_spec.rb +17 -17
  105. data/spec/unit/berkshelf_spec.rb +18 -18
  106. metadata +5 -5
@@ -1,30 +1,30 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Berkshelf::Config do
4
- describe '::file' do
5
- context 'when the file does not exist' do
4
+ describe "::file" do
5
+ context "when the file does not exist" do
6
6
  before { allow(File).to receive(:exists?).and_return(false) }
7
7
 
8
- it 'is nil' do
8
+ it "is nil" do
9
9
  expect(Berkshelf::Config.file).to be_nil
10
10
  end
11
11
  end
12
12
  end
13
13
 
14
- describe '::instance' do
15
- it 'should be a Berkshelf::Config' do
14
+ describe "::instance" do
15
+ it "should be a Berkshelf::Config" do
16
16
  expect(Berkshelf::Config.instance).to be_an_instance_of(Berkshelf::Config)
17
17
  end
18
18
 
19
- context 'attributes' do
20
- it 'should have a default API timeout' do
21
- expect(Berkshelf::Config.instance.api.timeout).to eq('30')
19
+ context "attributes" do
20
+ it "should have a default API timeout" do
21
+ expect(Berkshelf::Config.instance.api.timeout).to eq("30")
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
- describe '::path' do
27
- it 'is a string' do
26
+ describe "::path" do
27
+ it "is a string" do
28
28
  expect(Berkshelf::Config.path).to be_a(String)
29
29
  end
30
30
 
@@ -38,8 +38,8 @@ describe Berkshelf::Config do
38
38
 
39
39
  context "when ENV['BERKSHELF_CONFIG'] is used" do
40
40
  before do
41
- allow(ENV).to receive(:[]).with('BERKSHELF_CONFIG').and_return('/tmp/config.json')
42
- allow(File).to receive(:exists?).with('/tmp/config.json').and_return(true)
41
+ allow(ENV).to receive(:[]).with("BERKSHELF_CONFIG").and_return("/tmp/config.json")
42
+ allow(File).to receive(:exists?).with("/tmp/config.json").and_return(true)
43
43
  end
44
44
 
45
45
  it "points to a location within it" do
@@ -1,13 +1,13 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Berkshelf::CookbookGenerator do
4
- let(:name) { 'sparkle_motion' }
5
- let(:license) { 'reserved' }
6
- let(:maintainer) { 'Berkshelf Core' }
7
- let(:maintainer_email) { 'core@berkshelf.com' }
4
+ let(:name) { "sparkle_motion" }
5
+ let(:license) { "reserved" }
6
+ let(:maintainer) { "Berkshelf Core" }
7
+ let(:maintainer_email) { "core@berkshelf.com" }
8
8
 
9
9
  let(:target) { tmp_path.join(name) }
10
- let(:kitchen_generator) { double('kitchen-generator', invoke_all: nil) }
10
+ let(:kitchen_generator) { double("kitchen-generator", invoke_all: nil) }
11
11
 
12
12
  before do
13
13
  allow(Kitchen::Generator::Init)
@@ -16,66 +16,66 @@ describe Berkshelf::CookbookGenerator do
16
16
  .and_return(kitchen_generator)
17
17
  end
18
18
 
19
- context 'with default options' do
19
+ context "with default options" do
20
20
  before do
21
21
  capture(:stdout) do
22
22
  Berkshelf::CookbookGenerator.new([target, name],
23
23
  license: license,
24
24
  maintainer: maintainer,
25
- maintainer_email: maintainer_email,
25
+ maintainer_email: maintainer_email
26
26
  ).invoke_all
27
27
  end
28
28
  end
29
29
 
30
30
  it "generates a new cookbook" do
31
31
  expect(target).to have_structure {
32
- directory 'attributes'
33
- directory 'files' do
34
- directory 'default'
32
+ directory "attributes"
33
+ directory "files" do
34
+ directory "default"
35
35
  end
36
- directory 'libraries'
37
- directory 'providers'
38
- directory 'recipes' do
39
- file 'default.rb' do
40
- contains '# Cookbook Name:: sparkle_motion'
41
- contains '# Recipe:: default'
36
+ directory "libraries"
37
+ directory "providers"
38
+ directory "recipes" do
39
+ file "default.rb" do
40
+ contains "# Cookbook Name:: sparkle_motion"
41
+ contains "# Recipe:: default"
42
42
  contains "# Copyright (C) #{Time.now.year} Berkshelf Core"
43
- contains '# All rights reserved - Do Not Redistribute'
43
+ contains "# All rights reserved - Do Not Redistribute"
44
44
  end
45
45
  end
46
- directory 'resources'
47
- directory 'templates' do
48
- directory 'default'
46
+ directory "resources"
47
+ directory "templates" do
48
+ directory "default"
49
49
  end
50
- file 'LICENSE' do
50
+ file "LICENSE" do
51
51
  contains "Copyright (C) #{Time.now.year} Berkshelf Core"
52
- contains 'All rights reserved - Do Not Redistribute'
52
+ contains "All rights reserved - Do Not Redistribute"
53
53
  end
54
- file 'README.md' do
55
- contains '# sparkle_motion-cookbook'
56
- contains '### sparkle_motion::default'
54
+ file "README.md" do
55
+ contains "# sparkle_motion-cookbook"
56
+ contains "### sparkle_motion::default"
57
57
  contains " <td><tt>['sparkle_motion']['bacon']</tt></td>"
58
58
  contains "Include `sparkle_motion` in your node's `run_list`:"
59
59
  contains ' "recipe[sparkle_motion::default]"'
60
- contains 'Author:: Berkshelf Core (<core@berkshelf.com>)'
60
+ contains "Author:: Berkshelf Core (<core@berkshelf.com>)"
61
61
  end
62
- file 'CHANGELOG.md' do
63
- contains '# 0.1.0'
62
+ file "CHANGELOG.md" do
63
+ contains "# 0.1.0"
64
64
  contains "Initial release of sparkle_motion"
65
65
  end
66
- file 'metadata.rb' do
66
+ file "metadata.rb" do
67
67
  contains "name 'sparkle_motion'"
68
68
  contains "maintainer 'Berkshelf Core'"
69
69
  contains "maintainer_email 'core@berkshelf.com'"
70
70
  contains "license 'All rights reserved'"
71
71
  contains "description 'Installs/Configures sparkle_motion'"
72
72
  end
73
- file 'Berksfile' do
73
+ file "Berksfile" do
74
74
  contains 'source "https://supermarket.chef.io"'
75
- contains 'metadata'
75
+ contains "metadata"
76
76
  end
77
- file 'Gemfile'
78
- file 'chefignore'
77
+ file "Gemfile"
78
+ file "chefignore"
79
79
  }
80
80
  end
81
81
  end
@@ -83,15 +83,15 @@ describe Berkshelf::CookbookGenerator do
83
83
  context "given a 'maintainer_email' option" do
84
84
  before do
85
85
  allow(Kitchen::Generator::Init).to receive(:new).with(any_args()).and_return(kitchen_generator)
86
- capture(:stdout) {
87
- Berkshelf::CookbookGenerator.new([target, name], maintainer_email: 'jamie@vialstudios.com').invoke_all
88
- }
86
+ capture(:stdout) do
87
+ Berkshelf::CookbookGenerator.new([target, name], maintainer_email: "jamie@vialstudios.com").invoke_all
88
+ end
89
89
  end
90
90
 
91
91
  it "generates a metadata.rb with the 'maintainer_email' value set" do
92
92
  email = email
93
93
  expect(target).to have_structure {
94
- file 'metadata.rb' do
94
+ file "metadata.rb" do
95
95
  contains "maintainer_email 'jamie@vialstudios.com'"
96
96
  end
97
97
  }
@@ -100,7 +100,7 @@ describe Berkshelf::CookbookGenerator do
100
100
 
101
101
  context "given an invalid option for :license" do
102
102
  subject(:run) do
103
- capture(:stdout) { described_class.new([target, name], license: 'not-there').invoke_all }
103
+ capture(:stdout) { described_class.new([target, name], license: "not-there").invoke_all }
104
104
  end
105
105
 
106
106
  it "raises a LicenseNotFound error" do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Berkshelf::CookbookStore do
4
4
  describe "ClassMethods" do
@@ -6,8 +6,8 @@ describe Berkshelf::CookbookStore do
6
6
  describe "::import"
7
7
 
8
8
  describe "::new" do
9
- it 'creates the storage_path' do
10
- storage_path = tmp_path.join('random_storage')
9
+ it "creates the storage_path" do
10
+ storage_path = tmp_path.join("random_storage")
11
11
  Berkshelf::CookbookStore.new(storage_path)
12
12
 
13
13
  expect(storage_path).to exist
@@ -17,103 +17,103 @@ describe Berkshelf::CookbookStore do
17
17
 
18
18
  subject { Berkshelf::CookbookStore.new(tmp_path.join("cbstore_rspec")) }
19
19
 
20
- describe '#cookbook_path' do
21
- let(:cookbook_name) { 'nginx' }
22
- let(:cookbook_version) { '0.101.2' }
20
+ describe "#cookbook_path" do
21
+ let(:cookbook_name) { "nginx" }
22
+ let(:cookbook_version) { "0.101.2" }
23
23
  let(:path) { subject.cookbook_path(cookbook_name, cookbook_version) }
24
24
 
25
- it 'returns an instance of Pathname' do
25
+ it "returns an instance of Pathname" do
26
26
  expect(path).to be_a(Pathname)
27
27
  end
28
28
 
29
- it 'returns a the filepath within the storage path' do
29
+ it "returns a the filepath within the storage path" do
30
30
  expect(path.dirname).to eq(subject.storage_path)
31
31
  end
32
32
 
33
- it 'returns a basename containing the cookbook name and version separated by a dash' do
33
+ it "returns a basename containing the cookbook name and version separated by a dash" do
34
34
  expect(path.basename.to_s).to eq("#{cookbook_name}-#{cookbook_version}")
35
35
  end
36
36
  end
37
37
 
38
- describe '#satisfy' do
39
- let(:name) { 'nginx' }
40
- let(:version) { '0.101.4' }
41
- let(:constraint) { Semverse::Constraint.new('~> 0.101.2') }
42
- let(:cached_one) { double('cached-one', name: name, version: Semverse::Version.new(version)) }
43
- let(:cached_two) { double('cached-two', name: 'mysql', version: Semverse::Version.new('1.2.6')) }
38
+ describe "#satisfy" do
39
+ let(:name) { "nginx" }
40
+ let(:version) { "0.101.4" }
41
+ let(:constraint) { Semverse::Constraint.new("~> 0.101.2") }
42
+ let(:cached_one) { double("cached-one", name: name, version: Semverse::Version.new(version)) }
43
+ let(:cached_two) { double("cached-two", name: "mysql", version: Semverse::Version.new("1.2.6")) }
44
44
 
45
45
  before { allow(subject).to receive(:cookbooks).and_return([cached_one, cached_two]) }
46
46
 
47
- it 'gets and returns the the CachedCookbook best matching the name and constraint' do
47
+ it "gets and returns the the CachedCookbook best matching the name and constraint" do
48
48
  expect(subject).to receive(:cookbook).with(name, version).and_return(cached_one)
49
49
  result = subject.satisfy(name, constraint)
50
50
 
51
51
  expect(result).to eq(cached_one)
52
52
  end
53
53
 
54
- context 'when there are no cookbooks in the cookbook store' do
54
+ context "when there are no cookbooks in the cookbook store" do
55
55
  before { allow(subject).to receive(:cookbooks).and_return([]) }
56
56
 
57
- it 'returns nil' do
57
+ it "returns nil" do
58
58
  result = subject.satisfy(name, constraint)
59
59
  expect(result).to be_nil
60
60
  end
61
61
  end
62
62
 
63
- context 'when there is no matching cookbook for the given name and constraint' do
64
- let(:version) { Semverse::Version.new('1.0.0') }
65
- let(:constraint) { Semverse::Constraint.new('= 0.1.0') }
63
+ context "when there is no matching cookbook for the given name and constraint" do
64
+ let(:version) { Semverse::Version.new("1.0.0") }
65
+ let(:constraint) { Semverse::Constraint.new("= 0.1.0") }
66
66
 
67
- before { allow(subject).to receive(:cookbooks).and_return([ double('badcache', name: 'none', version: version) ]) }
67
+ before { allow(subject).to receive(:cookbooks).and_return([ double("badcache", name: "none", version: version) ]) }
68
68
 
69
- it 'returns nil if there is no matching cookbook for the name and constraint' do
69
+ it "returns nil if there is no matching cookbook for the name and constraint" do
70
70
  result = subject.satisfy(name, constraint)
71
71
  expect(result).to be_nil
72
72
  end
73
73
  end
74
74
  end
75
75
 
76
- describe '#cookbook' do
77
- subject { Berkshelf::CookbookStore.new(fixtures_path.join('cookbooks')) }
76
+ describe "#cookbook" do
77
+ subject { Berkshelf::CookbookStore.new(fixtures_path.join("cookbooks")) }
78
78
 
79
- it 'returns a CachedCookbook if the specified cookbook version exists' do
80
- expect(subject.cookbook('example_cookbook', '0.5.0')).to be_a(Berkshelf::CachedCookbook)
79
+ it "returns a CachedCookbook if the specified cookbook version exists" do
80
+ expect(subject.cookbook("example_cookbook", "0.5.0")).to be_a(Berkshelf::CachedCookbook)
81
81
  end
82
82
 
83
- it 'returns nil if the specified cookbook version does not exist' do
84
- expect(subject.cookbook('doesnotexist', '0.1.0')).to be_nil
83
+ it "returns nil if the specified cookbook version does not exist" do
84
+ expect(subject.cookbook("doesnotexist", "0.1.0")).to be_nil
85
85
  end
86
86
  end
87
87
 
88
- describe '#cookbooks' do
88
+ describe "#cookbooks" do
89
89
  before do
90
- generate_cookbook(subject.storage_path, 'nginx', '0.101.2')
91
- generate_cookbook(subject.storage_path, 'mysql', '1.2.6')
90
+ generate_cookbook(subject.storage_path, "nginx", "0.101.2")
91
+ generate_cookbook(subject.storage_path, "mysql", "1.2.6")
92
92
  end
93
93
 
94
- it 'returns a list of CachedCookbooks' do
94
+ it "returns a list of CachedCookbooks" do
95
95
  subject.cookbooks.each do |cookbook|
96
96
  expect(cookbook).to be_a(Berkshelf::CachedCookbook)
97
97
  end
98
98
  end
99
99
 
100
- it 'contains a CachedCookbook for every cookbook in the storage path' do
100
+ it "contains a CachedCookbook for every cookbook in the storage path" do
101
101
  expect(subject.cookbooks.size).to eq(2)
102
102
  end
103
103
 
104
- context 'given a value for the filter parameter' do
105
- it 'returns only the CachedCookbooks whose name match the filter' do
106
- expect(subject.cookbooks('mysql').size).to eq(1)
104
+ context "given a value for the filter parameter" do
105
+ it "returns only the CachedCookbooks whose name match the filter" do
106
+ expect(subject.cookbooks("mysql").size).to eq(1)
107
107
  end
108
108
  end
109
109
 
110
- context 'when a there is a cookbook without a name attribute' do
110
+ context "when a there is a cookbook without a name attribute" do
111
111
  before do
112
- generate_cookbook(subject.storage_path, 'foo', '3.0.1', without_name: true)
112
+ generate_cookbook(subject.storage_path, "foo", "3.0.1", without_name: true)
113
113
  end
114
114
 
115
- it 'omits the broken cookbook' do
116
- expect(subject.cookbooks('foo')).to be_empty
115
+ it "omits the broken cookbook" do
116
+ expect(subject.cookbooks("foo")).to be_empty
117
117
  end
118
118
  end
119
119
  end
@@ -1,9 +1,9 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe FileUtils do
4
- describe '#mv' do
5
- let(:src) { 'src' }
6
- let(:dest) { 'dest' }
4
+ describe "#mv" do
5
+ let(:src) { "src" }
6
+ let(:dest) { "dest" }
7
7
  let(:options) { {} }
8
8
 
9
9
  it "uses mv by default" do
@@ -11,8 +11,7 @@ describe FileUtils do
11
11
  FileUtils.mv(src, dest, options)
12
12
  end
13
13
 
14
-
15
- it 'replaces mv with cp_r and rm_rf' do
14
+ it "replaces mv with cp_r and rm_rf" do
16
15
  expect(FileUtils).to receive(:cp_r).with(src, dest, options)
17
16
  expect(FileUtils).to receive(:rm_rf).with(src)
18
17
 
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Pathname do
4
4
  describe "#cookbook?" do
@@ -1,88 +1,88 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Berkshelf::Dependency do
4
- let(:cookbook_name) { 'nginx' }
5
- let(:berksfile) { double('berksfile', filepath: fixtures_path.join('Berksfile').to_s) }
4
+ let(:cookbook_name) { "nginx" }
5
+ let(:berksfile) { double("berksfile", filepath: fixtures_path.join("Berksfile").to_s) }
6
6
 
7
7
  describe "ClassMethods" do
8
8
  describe "::new" do
9
9
  let(:source) { described_class.new(berksfile, cookbook_name) }
10
10
 
11
- context 'given no location key (i.e. :git, :path, :site)' do
12
- it 'sets a nil valie for location' do
11
+ context "given no location key (i.e. :git, :path, :site)" do
12
+ it "sets a nil valie for location" do
13
13
  expect(source.location).to be_nil
14
14
  end
15
15
  end
16
16
 
17
- context 'given no value for :locked_version' do
18
- it 'returns a wildcard match for any version' do
17
+ context "given no value for :locked_version" do
18
+ it "returns a wildcard match for any version" do
19
19
  expect(source.locked_version).to be_nil
20
20
  end
21
21
  end
22
22
 
23
- context 'given no value for :constraint' do
24
- it 'returns a wildcard match for any version' do
25
- expect(source.version_constraint.to_s).to eq('>= 0.0.0')
23
+ context "given no value for :constraint" do
24
+ it "returns a wildcard match for any version" do
25
+ expect(source.version_constraint.to_s).to eq(">= 0.0.0")
26
26
  end
27
27
  end
28
28
 
29
- context 'given a value for :constraint' do
30
- let(:source) { described_class.new(berksfile, cookbook_name, constraint: '~> 1.0.84') }
29
+ context "given a value for :constraint" do
30
+ let(:source) { described_class.new(berksfile, cookbook_name, constraint: "~> 1.0.84") }
31
31
 
32
- it 'returns a Semverse::Constraint for the given version for version_constraint' do
33
- expect(source.version_constraint.to_s).to eq('~> 1.0.84')
32
+ it "returns a Semverse::Constraint for the given version for version_constraint" do
33
+ expect(source.version_constraint.to_s).to eq("~> 1.0.84")
34
34
  end
35
35
  end
36
36
 
37
- context 'given a location key :git' do
38
- let(:url) { 'git://url_to_git' }
37
+ context "given a location key :git" do
38
+ let(:url) { "git://url_to_git" }
39
39
  let(:source) { described_class.new(berksfile, cookbook_name, git: url) }
40
40
 
41
- it 'initializes a GitLocation for location' do
41
+ it "initializes a GitLocation for location" do
42
42
  expect(source.location).to be_a(Berkshelf::GitLocation)
43
43
  end
44
44
 
45
- it 'points to the given Git URL' do
45
+ it "points to the given Git URL" do
46
46
  expect(source.location.uri).to eq(url)
47
47
  end
48
48
  end
49
49
 
50
- context 'given a location key :path' do
51
- context 'given a value for path that contains a cookbook' do
52
- let(:path) { fixtures_path.join('cookbooks', 'example_cookbook').to_s }
50
+ context "given a location key :path" do
51
+ context "given a value for path that contains a cookbook" do
52
+ let(:path) { fixtures_path.join("cookbooks", "example_cookbook").to_s }
53
53
  let(:location) { described_class.new(berksfile, cookbook_name, path: path).location }
54
54
 
55
- it 'initializes a PathLocation for location' do
55
+ it "initializes a PathLocation for location" do
56
56
  expect(location).to be_a(Berkshelf::PathLocation)
57
57
  end
58
58
 
59
- it 'points to the specified path' do
59
+ it "points to the specified path" do
60
60
  expect(location.options[:path]).to eq(path)
61
61
  end
62
62
  end
63
63
 
64
- context 'given a group option containing a single group' do
64
+ context "given a group option containing a single group" do
65
65
  let(:group) { :production }
66
66
  let(:source) { described_class.new(berksfile, cookbook_name, group: group) }
67
67
 
68
- it 'assigns the single group to the groups attribute' do
68
+ it "assigns the single group to the groups attribute" do
69
69
  expect(source.groups).to include(group)
70
70
  end
71
71
  end
72
72
 
73
- context 'given a group option containing an array of groups' do
73
+ context "given a group option containing an array of groups" do
74
74
  let(:groups) { [ :development, :test ] }
75
75
  let(:source) { described_class.new(berksfile, cookbook_name, group: groups) }
76
76
 
77
- it 'assigns all the groups to the group attribute' do
77
+ it "assigns all the groups to the group attribute" do
78
78
  expect(source.groups).to eq(groups)
79
79
  end
80
80
  end
81
81
 
82
- context 'given no group option' do
82
+ context "given no group option" do
83
83
  let(:source) { described_class.new(berksfile, cookbook_name) }
84
84
 
85
- it 'has the default group assigned' do
85
+ it "has the default group assigned" do
86
86
  expect(source.groups).to include(:default)
87
87
  end
88
88
  end
@@ -92,26 +92,26 @@ describe Berkshelf::Dependency do
92
92
 
93
93
  subject { described_class.new(berksfile, cookbook_name) }
94
94
 
95
- describe '#add_group' do
96
- it 'stores strings as symbols' do
97
- subject.add_group 'foo'
95
+ describe "#add_group" do
96
+ it "stores strings as symbols" do
97
+ subject.add_group "foo"
98
98
  expect(subject.groups).to eq([:default, :foo])
99
99
  end
100
100
 
101
- it 'does not store duplicate groups' do
102
- subject.add_group 'bar'
103
- subject.add_group 'bar'
101
+ it "does not store duplicate groups" do
102
+ subject.add_group "bar"
103
+ subject.add_group "bar"
104
104
  subject.add_group :bar
105
105
  expect(subject.groups).to eq([:default, :bar])
106
106
  end
107
107
 
108
- it 'adds multiple groups' do
109
- subject.add_group 'baz', 'quux'
108
+ it "adds multiple groups" do
109
+ subject.add_group "baz", "quux"
110
110
  expect(subject.groups).to eq([:default, :baz, :quux])
111
111
  end
112
112
 
113
- it 'handles multiple groups as an array' do
114
- subject.add_group ['baz', 'quux']
113
+ it "handles multiple groups as an array" do
114
+ subject.add_group %w{baz quux}
115
115
  expect(subject.groups).to eq([:default, :baz, :quux])
116
116
  end
117
117
  end
@@ -119,13 +119,13 @@ describe Berkshelf::Dependency do
119
119
  describe "#cached_cookbook"
120
120
  describe "#download"
121
121
 
122
- describe '#installed?' do
123
- it 'returns true if self.cached_cookbook is not nil' do
124
- allow(subject).to receive(:cached_cookbook) { double('cb') }
122
+ describe "#installed?" do
123
+ it "returns true if self.cached_cookbook is not nil" do
124
+ allow(subject).to receive(:cached_cookbook) { double("cb") }
125
125
  expect(subject.installed?).to be(true)
126
126
  end
127
127
 
128
- it 'returns false if self.cached_cookbook is nil' do
128
+ it "returns false if self.cached_cookbook is nil" do
129
129
  allow(subject).to receive(:cached_cookbook) { nil }
130
130
  expect(subject.installed?).to be(false)
131
131
  end