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,52 +1,52 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Berkshelf
4
4
  describe BaseLocation do
5
- let(:constraint) { double('constraint') }
6
- let(:dependency) { double('dependency', name: 'cookbook', version_constraint: constraint) }
5
+ let(:constraint) { double("constraint") }
6
+ let(:dependency) { double("dependency", name: "cookbook", version_constraint: constraint) }
7
7
 
8
8
  subject { described_class.new(dependency) }
9
9
 
10
- describe '#installed?' do
11
- it 'is an abstract function' do
10
+ describe "#installed?" do
11
+ it "is an abstract function" do
12
12
  expect { subject.installed? }.to raise_error(AbstractFunction)
13
13
  end
14
14
  end
15
15
 
16
- describe '#install' do
17
- it 'is an abstract function' do
16
+ describe "#install" do
17
+ it "is an abstract function" do
18
18
  expect { subject.install }.to raise_error(AbstractFunction)
19
19
  end
20
20
  end
21
21
 
22
- describe '#cached_cookbook' do
23
- it 'is an abstract function' do
22
+ describe "#cached_cookbook" do
23
+ it "is an abstract function" do
24
24
  expect { subject.cached_cookbook }.to raise_error(AbstractFunction)
25
25
  end
26
26
  end
27
27
 
28
- describe '#to_lock' do
29
- it 'is an abstract function' do
28
+ describe "#to_lock" do
29
+ it "is an abstract function" do
30
30
  expect { subject.to_lock }.to raise_error(AbstractFunction)
31
31
  end
32
32
  end
33
33
 
34
- describe '#validate_cached!' do
35
- context 'when the path is not a cookbook' do
34
+ describe "#validate_cached!" do
35
+ context "when the path is not a cookbook" do
36
36
  before { allow(File).to receive(:cookbook?).and_return(false) }
37
37
 
38
- it 'raises an error' do
39
- expect {
40
- subject.validate_cached!('/foo/bar')
41
- }.to raise_error(NotACookbook)
38
+ it "raises an error" do
39
+ expect do
40
+ subject.validate_cached!("/foo/bar")
41
+ end.to raise_error(NotACookbook)
42
42
  end
43
43
  end
44
44
 
45
- context 'when the path is a cookbook' do
45
+ context "when the path is a cookbook" do
46
46
  let(:cookbook) do
47
- double('cookbook',
48
- cookbook_name: 'cookbook',
49
- version: '0.1.0',
47
+ double("cookbook",
48
+ cookbook_name: "cookbook",
49
+ version: "0.1.0"
50
50
  )
51
51
  end
52
52
 
@@ -55,32 +55,32 @@ module Berkshelf
55
55
  allow(CachedCookbook).to receive(:from_path).and_return(cookbook)
56
56
  end
57
57
 
58
- it 'raises an error if the metadata does not have a name attribute' do
58
+ it "raises an error if the metadata does not have a name attribute" do
59
59
  allow(CachedCookbook).to receive(:from_path)
60
60
  .and_raise(ArgumentError)
61
61
 
62
- expect {
62
+ expect do
63
63
  subject.validate_cached!(cookbook)
64
- }.to raise_error(InternalError)
64
+ end.to raise_error(InternalError)
65
65
  end
66
66
 
67
- it 'raises an error if the constraint does not satisfy' do
68
- allow(constraint).to receive(:satisfies?).with('0.1.0').and_return(false)
69
- expect {
67
+ it "raises an error if the constraint does not satisfy" do
68
+ allow(constraint).to receive(:satisfies?).with("0.1.0").and_return(false)
69
+ expect do
70
70
  subject.validate_cached!(cookbook)
71
- }.to raise_error(CookbookValidationFailure)
71
+ end.to raise_error(CookbookValidationFailure)
72
72
  end
73
73
 
74
- it 'raises an error if the names do not match' do
75
- allow(constraint).to receive(:satisfies?).with('0.1.0').and_return(true)
76
- allow(cookbook).to receive(:cookbook_name).and_return('different_name')
77
- expect {
74
+ it "raises an error if the names do not match" do
75
+ allow(constraint).to receive(:satisfies?).with("0.1.0").and_return(true)
76
+ allow(cookbook).to receive(:cookbook_name).and_return("different_name")
77
+ expect do
78
78
  subject.validate_cached!(cookbook)
79
- }.to raise_error(MismatchedCookbookName)
79
+ end.to raise_error(MismatchedCookbookName)
80
80
  end
81
81
 
82
- it 'returns true when the validation succeeds' do
83
- allow(constraint).to receive(:satisfies?).with('0.1.0').and_return(true)
82
+ it "returns true when the validation succeeds" do
83
+ allow(constraint).to receive(:satisfies?).with("0.1.0").and_return(true)
84
84
  expect(subject.validate_cached!(cookbook)).to be(true)
85
85
  end
86
86
  end
@@ -1,100 +1,100 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Berkshelf
4
4
  describe GitLocation do
5
- let(:dependency) { double(name: 'bacon') }
5
+ let(:dependency) { double(name: "bacon") }
6
6
 
7
7
  subject do
8
- described_class.new(dependency, git: 'https://repo.com', branch: 'ham',
9
- tag: 'v1.2.3', ref: 'abc123', revision: 'defjkl123456', rel: 'hi')
8
+ described_class.new(dependency, git: "https://repo.com", branch: "ham",
9
+ tag: "v1.2.3", ref: "abc123", revision: "defjkl123456", rel: "hi")
10
10
  end
11
11
 
12
- describe '.initialize' do
13
- it 'sets the uri' do
14
- instance = described_class.new(dependency, git: 'https://repo.com')
15
- expect(instance.uri).to eq('https://repo.com')
12
+ describe ".initialize" do
13
+ it "sets the uri" do
14
+ instance = described_class.new(dependency, git: "https://repo.com")
15
+ expect(instance.uri).to eq("https://repo.com")
16
16
  end
17
17
 
18
- it 'sets the branch' do
18
+ it "sets the branch" do
19
19
  instance = described_class.new(dependency,
20
- git: 'https://repo.com', branch: 'magic_new_feature')
21
- expect(instance.branch).to eq('magic_new_feature')
20
+ git: "https://repo.com", branch: "magic_new_feature")
21
+ expect(instance.branch).to eq("magic_new_feature")
22
22
  end
23
23
 
24
- it 'sets the tag' do
24
+ it "sets the tag" do
25
25
  instance = described_class.new(dependency,
26
- git: 'https://repo.com', tag: 'v1.2.3')
27
- expect(instance.tag).to eq('v1.2.3')
26
+ git: "https://repo.com", tag: "v1.2.3")
27
+ expect(instance.tag).to eq("v1.2.3")
28
28
  end
29
29
 
30
- it 'adds the ref' do
30
+ it "adds the ref" do
31
31
  instance = described_class.new(dependency,
32
- git: 'https://repo.com', ref: 'abc123')
33
- expect(instance.ref).to eq('abc123')
32
+ git: "https://repo.com", ref: "abc123")
33
+ expect(instance.ref).to eq("abc123")
34
34
  end
35
35
 
36
- it 'sets the revision' do
36
+ it "sets the revision" do
37
37
  instance = described_class.new(dependency,
38
- git: 'https://repo.com', revision: 'abcde12345')
39
- expect(instance.revision).to eq('abcde12345')
38
+ git: "https://repo.com", revision: "abcde12345")
39
+ expect(instance.revision).to eq("abcde12345")
40
40
  end
41
41
 
42
- it 'sets the rel' do
42
+ it "sets the rel" do
43
43
  instance = described_class.new(dependency,
44
- git: 'https://repo.com', rel: 'internal/path')
45
- expect(instance.rel).to eq('internal/path')
44
+ git: "https://repo.com", rel: "internal/path")
45
+ expect(instance.rel).to eq("internal/path")
46
46
  end
47
47
 
48
- context 'rev_parse' do
48
+ context "rev_parse" do
49
49
  def rev_parse(instance)
50
50
  instance.instance_variable_get(:@rev_parse)
51
51
  end
52
52
 
53
- it 'uses the :ref option with priority' do
53
+ it "uses the :ref option with priority" do
54
54
  instance = described_class.new(dependency,
55
- git: 'https://repo.com', ref: 'abc123', branch: 'magic_new_feature')
56
- expect(rev_parse(instance)).to eq('abc123')
55
+ git: "https://repo.com", ref: "abc123", branch: "magic_new_feature")
56
+ expect(rev_parse(instance)).to eq("abc123")
57
57
  end
58
58
 
59
- it 'uses the :branch option with priority' do
59
+ it "uses the :branch option with priority" do
60
60
  instance = described_class.new(dependency,
61
- git: 'https://repo.com', branch: 'magic_new_feature', tag: 'v1.2.3')
62
- expect(rev_parse(instance)).to eq('magic_new_feature')
61
+ git: "https://repo.com", branch: "magic_new_feature", tag: "v1.2.3")
62
+ expect(rev_parse(instance)).to eq("magic_new_feature")
63
63
  end
64
64
 
65
- it 'uses the :tag option' do
65
+ it "uses the :tag option" do
66
66
  instance = described_class.new(dependency,
67
- git: 'https://repo.com', tag: 'v1.2.3')
68
- expect(rev_parse(instance)).to eq('v1.2.3')
67
+ git: "https://repo.com", tag: "v1.2.3")
68
+ expect(rev_parse(instance)).to eq("v1.2.3")
69
69
  end
70
70
 
71
71
  it 'uses "master" when none is given' do
72
- instance = described_class.new(dependency, git: 'https://repo.com')
73
- expect(rev_parse(instance)).to eq('master')
72
+ instance = described_class.new(dependency, git: "https://repo.com")
73
+ expect(rev_parse(instance)).to eq("master")
74
74
  end
75
75
  end
76
76
  end
77
77
 
78
- describe '#installed?' do
79
- it 'returns false when there is no revision' do
78
+ describe "#installed?" do
79
+ it "returns false when there is no revision" do
80
80
  allow(subject).to receive(:revision).and_return(nil)
81
81
  expect(subject.installed?).to be(false)
82
82
  end
83
83
 
84
- it 'returns false when the install_path does not exist' do
85
- allow(subject).to receive(:revision).and_return('abcd1234')
84
+ it "returns false when the install_path does not exist" do
85
+ allow(subject).to receive(:revision).and_return("abcd1234")
86
86
  allow(subject).to receive(:install_path).and_return(double(exist?: false))
87
87
  expect(subject.installed?).to be(false)
88
88
  end
89
89
 
90
- it 'returns true when the location is installed' do
91
- allow(subject).to receive(:revision).and_return('abcd1234')
90
+ it "returns true when the location is installed" do
91
+ allow(subject).to receive(:revision).and_return("abcd1234")
92
92
  allow(subject).to receive(:install_path).and_return(double(exist?: true))
93
93
  expect(subject.installed?).to be(true)
94
94
  end
95
95
  end
96
96
 
97
- describe '#install' do
97
+ describe "#install" do
98
98
  before do
99
99
  allow(File).to receive(:chmod)
100
100
  allow(FileUtils).to receive(:cp_r)
@@ -102,8 +102,8 @@ module Berkshelf
102
102
  allow(subject).to receive(:git)
103
103
  end
104
104
 
105
- context 'when the repository is cached' do
106
- it 'pulls a new version' do
105
+ context "when the repository is cached" do
106
+ it "pulls a new version" do
107
107
  allow(Dir).to receive(:chdir) { |args, &b| b.call } # Force eval the chdir block
108
108
 
109
109
  allow(subject).to receive(:cached?).and_return(true)
@@ -114,27 +114,27 @@ module Berkshelf
114
114
  end
115
115
  end
116
116
 
117
- context 'when the revision is not cached' do
118
- it 'clones the repository' do
117
+ context "when the revision is not cached" do
118
+ it "clones the repository" do
119
119
  allow(Dir).to receive(:chdir) { |args, &b| b.call } # Force eval the chdir block
120
120
 
121
121
  cache_path = subject.send(:cache_path)
122
122
  allow(subject).to receive(:cached?).and_return(false)
123
123
  expect(subject).to receive(:git).with(
124
- %|clone https://repo.com "#{cache_path}" --bare --no-hardlinks|
124
+ %{clone https://repo.com "#{cache_path}" --bare --no-hardlinks}
125
125
  )
126
126
  subject.install
127
127
  end
128
128
  end
129
129
  end
130
130
 
131
- describe '#cached_cookbook' do
132
- it 'returns nil if the cookbook is not installed' do
131
+ describe "#cached_cookbook" do
132
+ it "returns nil if the cookbook is not installed" do
133
133
  allow(subject).to receive(:installed?).and_return(false)
134
134
  expect(subject.cached_cookbook).to be_nil
135
135
  end
136
136
 
137
- it 'returns the cookbook at the install_path' do
137
+ it "returns the cookbook at the install_path" do
138
138
  allow(subject).to receive(:installed?).and_return(true)
139
139
  allow(CachedCookbook).to receive(:from_path)
140
140
 
@@ -143,69 +143,69 @@ module Berkshelf
143
143
  end
144
144
  end
145
145
 
146
- describe '#==' do
146
+ describe "#==" do
147
147
  let(:other) { subject.dup }
148
148
 
149
- it 'returns true when everything matches' do
149
+ it "returns true when everything matches" do
150
150
  expect(subject).to eq(other)
151
151
  end
152
152
 
153
- it 'returns false when the other location is not an GitLocation' do
153
+ it "returns false when the other location is not an GitLocation" do
154
154
  allow(other).to receive(:is_a?).and_return(false)
155
155
  expect(subject).to_not eq(other)
156
156
  end
157
157
 
158
- it 'returns false when the uri is different' do
159
- allow(other).to receive(:uri).and_return('different')
158
+ it "returns false when the uri is different" do
159
+ allow(other).to receive(:uri).and_return("different")
160
160
  expect(subject).to_not eq(other)
161
161
  end
162
162
 
163
- it 'returns false when the branch is different' do
164
- allow(other).to receive(:branch).and_return('different')
163
+ it "returns false when the branch is different" do
164
+ allow(other).to receive(:branch).and_return("different")
165
165
  expect(subject).to_not eq(other)
166
166
  end
167
167
 
168
- it 'returns false when the tag is different' do
169
- allow(other).to receive(:tag).and_return('different')
168
+ it "returns false when the tag is different" do
169
+ allow(other).to receive(:tag).and_return("different")
170
170
  expect(subject).to_not eq(other)
171
171
  end
172
172
 
173
- it 'returns false when the ref is different' do
174
- allow(other).to receive(:ref).and_return('different')
173
+ it "returns false when the ref is different" do
174
+ allow(other).to receive(:ref).and_return("different")
175
175
  expect(subject).to_not eq(other)
176
176
  end
177
177
 
178
- it 'returns false when the rel is different' do
179
- allow(other).to receive(:rel).and_return('different')
178
+ it "returns false when the rel is different" do
179
+ allow(other).to receive(:rel).and_return("different")
180
180
  expect(subject).to_not eq(other)
181
181
  end
182
182
  end
183
183
 
184
- describe '#to_s' do
185
- it 'prefers the tag' do
186
- expect(subject.to_s).to eq('https://repo.com (at v1.2.3/hi)')
184
+ describe "#to_s" do
185
+ it "prefers the tag" do
186
+ expect(subject.to_s).to eq("https://repo.com (at v1.2.3/hi)")
187
187
  end
188
188
 
189
- it 'prefers the branch' do
189
+ it "prefers the branch" do
190
190
  allow(subject).to receive(:tag).and_return(nil)
191
- expect(subject.to_s).to eq('https://repo.com (at ham/hi)')
191
+ expect(subject.to_s).to eq("https://repo.com (at ham/hi)")
192
192
  end
193
193
 
194
- it 'falls back to the ref' do
194
+ it "falls back to the ref" do
195
195
  allow(subject).to receive(:tag).and_return(nil)
196
196
  allow(subject).to receive(:branch).and_return(nil)
197
- expect(subject.to_s).to eq('https://repo.com (at abc123/hi)')
197
+ expect(subject.to_s).to eq("https://repo.com (at abc123/hi)")
198
198
  end
199
199
 
200
- it 'does not use the rel if missing' do
200
+ it "does not use the rel if missing" do
201
201
  allow(subject).to receive(:rel).and_return(nil)
202
- expect(subject.to_s).to eq('https://repo.com (at v1.2.3)')
202
+ expect(subject.to_s).to eq("https://repo.com (at v1.2.3)")
203
203
  end
204
204
  end
205
205
 
206
- describe '#to_lock' do
207
- it 'includes all the information' do
208
- expect(subject.to_lock).to eq <<-EOH.gsub(/^ {8}/, '')
206
+ describe "#to_lock" do
207
+ it "includes all the information" do
208
+ expect(subject.to_lock).to eq <<-EOH.gsub(/^ {8}/, "")
209
209
  git: https://repo.com
210
210
  revision: defjkl123456
211
211
  ref: abc123
@@ -215,34 +215,34 @@ module Berkshelf
215
215
  EOH
216
216
  end
217
217
 
218
- it 'does not include the branch if missing' do
218
+ it "does not include the branch if missing" do
219
219
  allow(subject).to receive(:branch).and_return(nil)
220
- expect(subject.to_lock).to_not include('branch')
220
+ expect(subject.to_lock).to_not include("branch")
221
221
  end
222
222
 
223
- it 'does not include the tag if missing' do
223
+ it "does not include the tag if missing" do
224
224
  allow(subject).to receive(:tag).and_return(nil)
225
- expect(subject.to_lock).to_not include('tag')
225
+ expect(subject.to_lock).to_not include("tag")
226
226
  end
227
227
 
228
- it 'does not include the rel if missing' do
228
+ it "does not include the rel if missing" do
229
229
  allow(subject).to receive(:rel).and_return(nil)
230
- expect(subject.to_lock).to_not include('rel')
230
+ expect(subject.to_lock).to_not include("rel")
231
231
  end
232
232
  end
233
233
 
234
- describe '#git' do
234
+ describe "#git" do
235
235
  before { described_class.send(:public, :git) }
236
236
 
237
- it 'raises an error if Git is not installed' do
237
+ it "raises an error if Git is not installed" do
238
238
  allow(Berkshelf).to receive(:which).and_return(false)
239
- expect { subject.git('foo') }.to raise_error(GitNotInstalled)
239
+ expect { subject.git("foo") }.to raise_error(GitNotInstalled)
240
240
  end
241
241
 
242
- it 'raises an error if the command fails' do
243
- shell_out = double('shell_out', success?: false, stderr: nil)
242
+ it "raises an error if the command fails" do
243
+ shell_out = double("shell_out", success?: false, stderr: nil)
244
244
  allow(Buff::ShellOut).to receive(:shell_out).and_return(shell_out)
245
- expect { subject.git('foo') }.to raise_error(GitCommandError)
245
+ expect { subject.git("foo") }.to raise_error(GitCommandError)
246
246
  end
247
247
  end
248
248
  end
@@ -1,104 +1,104 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Berkshelf
4
4
  describe PathLocation do
5
- let(:berksfile) { double('berksfile', filepath: __FILE__) }
6
- let(:constraint) { double('constraint', satisfies?: true) }
5
+ let(:berksfile) { double("berksfile", filepath: __FILE__) }
6
+ let(:constraint) { double("constraint", satisfies?: true) }
7
7
  let(:dependency) do
8
- double('dependency',
9
- name: 'nginx',
8
+ double("dependency",
9
+ name: "nginx",
10
10
  version_constraint: constraint,
11
- berksfile: berksfile,
11
+ berksfile: berksfile
12
12
  )
13
13
  end
14
- let(:path) { fixtures_path.join('cookbooks', 'example_cookbook') }
15
- let(:relative_path) { Pathname.new('../../../fixtures/cookbooks/example_cookbook') }
14
+ let(:path) { fixtures_path.join("cookbooks", "example_cookbook") }
15
+ let(:relative_path) { Pathname.new("../../../fixtures/cookbooks/example_cookbook") }
16
16
 
17
17
  subject { described_class.new(dependency, path: path) }
18
18
 
19
- describe '#installed?' do
20
- it 'returns false' do
19
+ describe "#installed?" do
20
+ it "returns false" do
21
21
  expect(subject.installed?).to be(false)
22
22
  end
23
23
  end
24
24
 
25
- describe '#install' do
26
- it 'validates the cached cookbook' do
25
+ describe "#install" do
26
+ it "validates the cached cookbook" do
27
27
  expect(subject).to receive(:validate_cached!).with(path)
28
28
  subject.install
29
29
  end
30
30
  end
31
31
 
32
- describe '#cached_cookbook' do
33
- it 'loads the cached cookbook at the path' do
32
+ describe "#cached_cookbook" do
33
+ it "loads the cached cookbook at the path" do
34
34
  expect(CachedCookbook).to receive(:from_path).with(path)
35
35
  subject.cached_cookbook
36
36
  end
37
37
  end
38
38
 
39
- describe '#relative_path' do
40
- it 'returns the path to the Berksfile' do
39
+ describe "#relative_path" do
40
+ it "returns the path to the Berksfile" do
41
41
  expect(subject.relative_path).to eq(relative_path)
42
42
  end
43
43
  end
44
44
 
45
- describe '#expanded_path' do
46
- it 'returns the expanded path, relative to the Berksfile' do
45
+ describe "#expanded_path" do
46
+ it "returns the expanded path, relative to the Berksfile" do
47
47
  absolute_path = Pathname.new(File.expand_path(relative_path, File.dirname(berksfile.filepath)))
48
48
  expect(subject.expanded_path).to eq(absolute_path)
49
49
  end
50
50
  end
51
51
 
52
- describe '#==' do
53
- it 'is false when compared with a non-PathLocation' do
54
- this = PathLocation.new(dependency, path: '.')
55
- that = 'A string'
52
+ describe "#==" do
53
+ it "is false when compared with a non-PathLocation" do
54
+ this = PathLocation.new(dependency, path: ".")
55
+ that = "A string"
56
56
  expect(this).to_not eq(that)
57
57
  end
58
58
 
59
- it 'is false when the metadata? is not the same' do
60
- this = PathLocation.new(dependency, path: '.')
61
- that = PathLocation.new(dependency, path: '.', metadata: true)
59
+ it "is false when the metadata? is not the same" do
60
+ this = PathLocation.new(dependency, path: ".")
61
+ that = PathLocation.new(dependency, path: ".", metadata: true)
62
62
  expect(this).to_not eq(that)
63
63
  end
64
64
 
65
- it 'is false when the expanded paths are different' do
66
- this = PathLocation.new(dependency, path: '.')
67
- that = PathLocation.new(dependency, path: '..')
65
+ it "is false when the expanded paths are different" do
66
+ this = PathLocation.new(dependency, path: ".")
67
+ that = PathLocation.new(dependency, path: "..")
68
68
  expect(this).to_not eq(that)
69
69
  end
70
70
 
71
- it 'is true when they are the same' do
72
- this = PathLocation.new(dependency, path: '.', metadata: true)
73
- that = PathLocation.new(dependency, path: '.', metadata: true)
71
+ it "is true when they are the same" do
72
+ this = PathLocation.new(dependency, path: ".", metadata: true)
73
+ that = PathLocation.new(dependency, path: ".", metadata: true)
74
74
  expect(this).to eq(that)
75
75
  end
76
76
  end
77
77
 
78
- describe '#to_lock' do
79
- it 'includes the path relative to the Berksfile' do
80
- expect(subject.to_lock).to eq <<-EOH.gsub(/^ {10}/, '')
78
+ describe "#to_lock" do
79
+ it "includes the path relative to the Berksfile" do
80
+ expect(subject.to_lock).to eq <<-EOH.gsub(/^ {10}/, "")
81
81
  path: #{relative_path}
82
82
  EOH
83
83
  end
84
84
 
85
- it 'includes the metadata attribute' do
85
+ it "includes the metadata attribute" do
86
86
  allow(subject).to receive(:metadata?).and_return(true)
87
- expect(subject.to_lock).to eq <<-EOH.gsub(/^ {10}/, '')
87
+ expect(subject.to_lock).to eq <<-EOH.gsub(/^ {10}/, "")
88
88
  path: #{relative_path}
89
89
  metadata: true
90
90
  EOH
91
91
  end
92
92
  end
93
93
 
94
- describe '#to_s' do
95
- it 'uses the relative path' do
94
+ describe "#to_s" do
95
+ it "uses the relative path" do
96
96
  expect(subject.to_s).to eq("source at #{relative_path}")
97
97
  end
98
98
  end
99
99
 
100
- describe '#inspect' do
101
- it 'includes the right information' do
100
+ describe "#inspect" do
101
+ it "includes the right information" do
102
102
  allow(subject).to receive(:metadata?).and_return(true)
103
103
  expect(subject.inspect).to eq("#<Berkshelf::PathLocation metadata: true, path: #{relative_path}>")
104
104
  end