berkshelf 5.2.0 → 8.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +19 -47
  3. data/Rakefile +14 -4
  4. data/berkshelf.gemspec +61 -40
  5. data/bin/berks +2 -2
  6. data/lib/berkshelf/api-client.rb +1 -0
  7. data/lib/berkshelf/api_client/chef_server_connection.rb +29 -0
  8. data/lib/berkshelf/api_client/connection.rb +57 -0
  9. data/lib/berkshelf/api_client/errors.rb +10 -0
  10. data/lib/berkshelf/api_client/remote_cookbook.rb +56 -0
  11. data/lib/berkshelf/api_client/version.rb +5 -0
  12. data/lib/berkshelf/api_client.rb +24 -0
  13. data/lib/berkshelf/berksfile.rb +149 -122
  14. data/lib/berkshelf/cached_cookbook.rb +127 -24
  15. data/lib/berkshelf/chef_config_compat.rb +51 -0
  16. data/lib/berkshelf/chef_repo_universe.rb +47 -0
  17. data/lib/berkshelf/cli.rb +143 -174
  18. data/lib/berkshelf/commands/shelf.rb +20 -19
  19. data/lib/berkshelf/community_rest.rb +59 -94
  20. data/lib/berkshelf/config.rb +97 -127
  21. data/lib/berkshelf/cookbook_store.rb +7 -6
  22. data/lib/berkshelf/core_ext/file.rb +1 -1
  23. data/lib/berkshelf/core_ext/file_utils.rb +4 -4
  24. data/lib/berkshelf/core_ext.rb +1 -1
  25. data/lib/berkshelf/dependency.rb +25 -32
  26. data/lib/berkshelf/downloader.rb +66 -39
  27. data/lib/berkshelf/errors.rb +23 -17
  28. data/lib/berkshelf/file_syncer.rb +24 -47
  29. data/lib/berkshelf/formatters/human.rb +7 -5
  30. data/lib/berkshelf/formatters/json.rb +6 -6
  31. data/lib/berkshelf/installer.rb +120 -111
  32. data/lib/berkshelf/location.rb +14 -14
  33. data/lib/berkshelf/locations/base.rb +1 -1
  34. data/lib/berkshelf/locations/git.rb +16 -24
  35. data/lib/berkshelf/locations/github.rb +2 -2
  36. data/lib/berkshelf/locations/path.rb +2 -2
  37. data/lib/berkshelf/lockfile.rb +326 -328
  38. data/lib/berkshelf/logger.rb +64 -1
  39. data/lib/berkshelf/mixin/git.rb +6 -5
  40. data/lib/berkshelf/packager.rb +44 -10
  41. data/lib/berkshelf/resolver/graph.rb +1 -1
  42. data/lib/berkshelf/resolver.rb +4 -4
  43. data/lib/berkshelf/ridley_compat.rb +109 -0
  44. data/lib/berkshelf/shell.rb +2 -1
  45. data/lib/berkshelf/shell_out.rb +18 -0
  46. data/lib/berkshelf/source.rb +77 -33
  47. data/lib/berkshelf/source_uri.rb +4 -4
  48. data/lib/berkshelf/ssl_policies.rb +38 -0
  49. data/lib/berkshelf/thor.rb +1 -1
  50. data/lib/berkshelf/thor_ext/hash_with_indifferent_access.rb +1 -1
  51. data/lib/berkshelf/thor_ext.rb +1 -1
  52. data/lib/berkshelf/uploader.rb +106 -70
  53. data/lib/berkshelf/validator.rb +13 -5
  54. data/lib/berkshelf/version.rb +1 -1
  55. data/lib/berkshelf/visualizer.rb +16 -11
  56. data/lib/berkshelf.rb +106 -81
  57. data/spec/config/knife.rb +4 -4
  58. data/spec/data/trusted_certs/example.crt +22 -0
  59. data/spec/fixtures/Berksfile +3 -3
  60. data/spec/fixtures/complex-cookbook-path/cookbooks/app/metadata.rb +2 -0
  61. data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins/metadata.rb +2 -0
  62. data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins-config/metadata.rb +4 -0
  63. data/spec/fixtures/cookbook-path/jenkins-config/metadata.rb +3 -3
  64. data/spec/fixtures/cookbook-path-uploader/apt-2.3.6/metadata.rb +2 -0
  65. data/spec/fixtures/cookbook-path-uploader/build-essential-1.4.2/metadata.rb +2 -0
  66. data/spec/fixtures/cookbook-path-uploader/jenkins-2.0.3/metadata.rb +5 -0
  67. data/spec/fixtures/cookbook-path-uploader/jenkins-config-0.1.0/metadata.rb +4 -0
  68. data/spec/fixtures/cookbook-path-uploader/runit-1.5.8/metadata.rb +5 -0
  69. data/spec/fixtures/cookbook-path-uploader/yum-3.0.6/metadata.rb +2 -0
  70. data/spec/fixtures/cookbook-path-uploader/yum-epel-0.2.0/metadata.rb +3 -0
  71. data/spec/fixtures/cookbook-store/jenkins-2.0.3/metadata.rb +5 -5
  72. data/spec/fixtures/cookbook-store/jenkins-2.0.4/metadata.rb +4 -4
  73. data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +3 -3
  74. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +3 -3
  75. data/spec/spec_helper.rb +56 -64
  76. data/spec/support/chef_api.rb +15 -16
  77. data/spec/support/chef_server.rb +71 -69
  78. data/spec/support/git.rb +59 -58
  79. data/spec/support/kitchen.rb +0 -14
  80. data/spec/support/matchers/file_system_matchers.rb +4 -5
  81. data/spec/support/matchers/filepath_matchers.rb +2 -2
  82. data/spec/support/path_helpers.rb +17 -17
  83. data/spec/support/shared_examples/formatter.rb +1 -1
  84. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/attributes/default.rb +0 -0
  85. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/files/default/file.h +0 -0
  86. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/metadata.rb +2 -0
  87. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/recipes/default.rb +0 -0
  88. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/templates/default/template.erb +0 -0
  89. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/attributes/default.rb +0 -0
  90. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/files/default/file.h +0 -0
  91. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/metadata.rb +2 -0
  92. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/recipes/default.rb +0 -0
  93. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/templates/default/template.erb +0 -0
  94. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/attributes/default.rb +0 -0
  95. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/files/default/file.h +0 -0
  96. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/metadata.rb +2 -0
  97. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/recipes/default.rb +0 -0
  98. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/templates/default/template.erb +0 -0
  99. data/spec/unit/berkshelf/berksfile_spec.rb +84 -105
  100. data/spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb +65 -0
  101. data/spec/unit/berkshelf/berkshelf/api_client/connection_spec.rb +157 -0
  102. data/spec/unit/berkshelf/berkshelf/api_client/remote_cookbook_spec.rb +23 -0
  103. data/spec/unit/berkshelf/berkshelf/api_client_spec.rb +9 -0
  104. data/spec/unit/berkshelf/cached_cookbook_spec.rb +45 -47
  105. data/spec/unit/berkshelf/chef_repo_universe_spec.rb +37 -0
  106. data/spec/unit/berkshelf/cli_spec.rb +7 -8
  107. data/spec/unit/berkshelf/community_rest_spec.rb +82 -90
  108. data/spec/unit/berkshelf/config_spec.rb +51 -22
  109. data/spec/unit/berkshelf/cookbook_store_spec.rb +41 -41
  110. data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +7 -8
  111. data/spec/unit/berkshelf/core_ext/pathname_spec.rb +1 -1
  112. data/spec/unit/berkshelf/dependency_spec.rb +48 -48
  113. data/spec/unit/berkshelf/downloader_spec.rb +191 -34
  114. data/spec/unit/berkshelf/errors_spec.rb +3 -3
  115. data/spec/unit/berkshelf/file_syncer_spec.rb +87 -87
  116. data/spec/unit/berkshelf/formatters/base_spec.rb +23 -23
  117. data/spec/unit/berkshelf/formatters/human_spec.rb +2 -2
  118. data/spec/unit/berkshelf/formatters/json_spec.rb +2 -2
  119. data/spec/unit/berkshelf/formatters/null_spec.rb +3 -3
  120. data/spec/unit/berkshelf/installer_spec.rb +8 -8
  121. data/spec/unit/berkshelf/location_spec.rb +11 -11
  122. data/spec/unit/berkshelf/locations/base_spec.rb +35 -36
  123. data/spec/unit/berkshelf/locations/git_spec.rb +90 -93
  124. data/spec/unit/berkshelf/locations/path_spec.rb +40 -41
  125. data/spec/unit/berkshelf/lockfile_parser_spec.rb +71 -71
  126. data/spec/unit/berkshelf/lockfile_spec.rb +205 -211
  127. data/spec/unit/berkshelf/logger_spec.rb +3 -3
  128. data/spec/unit/berkshelf/mixin/logging_spec.rb +5 -5
  129. data/spec/unit/berkshelf/packager_spec.rb +2 -2
  130. data/spec/unit/berkshelf/resolver/graph_spec.rb +10 -8
  131. data/spec/unit/berkshelf/resolver_spec.rb +17 -17
  132. data/spec/unit/berkshelf/ridley_compat_spec.rb +16 -0
  133. data/spec/unit/berkshelf/shell_spec.rb +34 -34
  134. data/spec/unit/berkshelf/source_spec.rb +186 -20
  135. data/spec/unit/berkshelf/source_uri_spec.rb +1 -1
  136. data/spec/unit/berkshelf/ssl_policies_spec.rb +86 -0
  137. data/spec/unit/berkshelf/uploader_spec.rb +146 -64
  138. data/spec/unit/berkshelf/validator_spec.rb +23 -16
  139. data/spec/unit/berkshelf/visualizer_spec.rb +24 -15
  140. data/spec/unit/berkshelf_spec.rb +18 -18
  141. metadata +138 -289
  142. data/.gitignore +0 -29
  143. data/.travis.yml +0 -64
  144. data/CHANGELOG.legacy.md +0 -307
  145. data/CHANGELOG.md +0 -1358
  146. data/CONTRIBUTING.md +0 -64
  147. data/Gemfile.lock +0 -399
  148. data/Guardfile +0 -23
  149. data/PLUGINS.md +0 -25
  150. data/README.md +0 -70
  151. data/Thorfile +0 -61
  152. data/appveyor.yml +0 -31
  153. data/docs/berkshelf_for_newcomers.md +0 -65
  154. data/features/berksfile.feature +0 -46
  155. data/features/commands/apply.feature +0 -41
  156. data/features/commands/contingent.feature +0 -48
  157. data/features/commands/cookbook.feature +0 -35
  158. data/features/commands/info.feature +0 -99
  159. data/features/commands/init.feature +0 -27
  160. data/features/commands/install.feature +0 -636
  161. data/features/commands/list.feature +0 -78
  162. data/features/commands/outdated.feature +0 -130
  163. data/features/commands/package.feature +0 -17
  164. data/features/commands/search.feature +0 -17
  165. data/features/commands/shelf/list.feature +0 -32
  166. data/features/commands/shelf/show.feature +0 -143
  167. data/features/commands/shelf/uninstall.feature +0 -96
  168. data/features/commands/show.feature +0 -83
  169. data/features/commands/update.feature +0 -142
  170. data/features/commands/upload.feature +0 -426
  171. data/features/commands/vendor.feature +0 -111
  172. data/features/commands/verify.feature +0 -29
  173. data/features/commands/viz.feature +0 -66
  174. data/features/community_site.feature +0 -37
  175. data/features/config.feature +0 -111
  176. data/features/help.feature +0 -11
  177. data/features/json_formatter.feature +0 -161
  178. data/features/lifecycle.feature +0 -378
  179. data/features/lockfile.feature +0 -378
  180. data/features/step_definitions/berksfile_steps.rb +0 -39
  181. data/features/step_definitions/chef/config_steps.rb +0 -12
  182. data/features/step_definitions/chef_server_steps.rb +0 -60
  183. data/features/step_definitions/cli_steps.rb +0 -18
  184. data/features/step_definitions/config_steps.rb +0 -46
  185. data/features/step_definitions/environment_steps.rb +0 -7
  186. data/features/step_definitions/filesystem_steps.rb +0 -269
  187. data/features/step_definitions/gem_steps.rb +0 -13
  188. data/features/step_definitions/json_steps.rb +0 -23
  189. data/features/step_definitions/utility_steps.rb +0 -11
  190. data/features/support/aruba.rb +0 -12
  191. data/features/support/env.rb +0 -82
  192. data/generator_files/Berksfile.erb +0 -11
  193. data/generator_files/CHANGELOG.md.erb +0 -3
  194. data/generator_files/Gemfile.erb +0 -8
  195. data/generator_files/README.md.erb +0 -42
  196. data/generator_files/Thorfile.erb +0 -11
  197. data/generator_files/Vagrantfile.erb +0 -117
  198. data/generator_files/chefignore +0 -94
  199. data/generator_files/default_recipe.erb +0 -6
  200. data/generator_files/default_test.rb.erb +0 -11
  201. data/generator_files/gitignore.erb +0 -23
  202. data/generator_files/helpers.rb.erb +0 -7
  203. data/generator_files/licenses/apachev2.erb +0 -13
  204. data/generator_files/licenses/gplv2.erb +0 -15
  205. data/generator_files/licenses/gplv3.erb +0 -14
  206. data/generator_files/licenses/mit.erb +0 -20
  207. data/generator_files/licenses/reserved.erb +0 -3
  208. data/generator_files/metadata.rb.erb +0 -11
  209. data/lib/berkshelf/base_generator.rb +0 -43
  210. data/lib/berkshelf/commands/test_command.rb +0 -13
  211. data/lib/berkshelf/cookbook_generator.rb +0 -133
  212. data/lib/berkshelf/init_generator.rb +0 -195
  213. data/spec/fixtures/cookbooks/example_cookbook/.gitignore +0 -2
  214. data/spec/fixtures/cookbooks/example_cookbook/.kitchen.yml +0 -26
  215. data/spec/unit/berkshelf/cookbook_generator_spec.rb +0 -110
  216. data/spec/unit/berkshelf/init_generator_spec.rb +0 -263
@@ -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,39 +102,36 @@ 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
107
- allow(Dir).to receive(:chdir) { |args, &b| b.call } # Force eval the chdir block
108
-
105
+ context "when the repository is cached" do
106
+ it "pulls a new version" do
107
+ cache_path = subject.send(:cache_path)
109
108
  allow(subject).to receive(:cached?).and_return(true)
110
109
  expect(subject).to receive(:git).with(
111
- 'fetch --force --tags https://repo.com "refs/heads/*:refs/heads/*"'
110
+ 'fetch --force --tags https://repo.com "refs/heads/*:refs/heads/*"', cwd: cache_path.to_s
112
111
  )
113
112
  subject.install
114
113
  end
115
114
  end
116
115
 
117
- context 'when the revision is not cached' do
118
- it 'clones the repository' do
119
- allow(Dir).to receive(:chdir) { |args, &b| b.call } # Force eval the chdir block
120
-
116
+ context "when the revision is not cached" do
117
+ it "clones the repository" do
121
118
  cache_path = subject.send(:cache_path)
122
119
  allow(subject).to receive(:cached?).and_return(false)
123
120
  expect(subject).to receive(:git).with(
124
- %|clone https://repo.com "#{cache_path}" --bare --no-hardlinks|
121
+ %{clone https://repo.com "#{cache_path}" --bare --no-hardlinks}
125
122
  )
126
123
  subject.install
127
124
  end
128
125
  end
129
126
  end
130
127
 
131
- describe '#cached_cookbook' do
132
- it 'returns nil if the cookbook is not installed' do
128
+ describe "#cached_cookbook" do
129
+ it "returns nil if the cookbook is not installed" do
133
130
  allow(subject).to receive(:installed?).and_return(false)
134
131
  expect(subject.cached_cookbook).to be_nil
135
132
  end
136
133
 
137
- it 'returns the cookbook at the install_path' do
134
+ it "returns the cookbook at the install_path" do
138
135
  allow(subject).to receive(:installed?).and_return(true)
139
136
  allow(CachedCookbook).to receive(:from_path)
140
137
 
@@ -143,69 +140,69 @@ module Berkshelf
143
140
  end
144
141
  end
145
142
 
146
- describe '#==' do
143
+ describe "#==" do
147
144
  let(:other) { subject.dup }
148
145
 
149
- it 'returns true when everything matches' do
146
+ it "returns true when everything matches" do
150
147
  expect(subject).to eq(other)
151
148
  end
152
149
 
153
- it 'returns false when the other location is not an GitLocation' do
150
+ it "returns false when the other location is not an GitLocation" do
154
151
  allow(other).to receive(:is_a?).and_return(false)
155
152
  expect(subject).to_not eq(other)
156
153
  end
157
154
 
158
- it 'returns false when the uri is different' do
159
- allow(other).to receive(:uri).and_return('different')
155
+ it "returns false when the uri is different" do
156
+ allow(other).to receive(:uri).and_return("different")
160
157
  expect(subject).to_not eq(other)
161
158
  end
162
159
 
163
- it 'returns false when the branch is different' do
164
- allow(other).to receive(:branch).and_return('different')
160
+ it "returns false when the branch is different" do
161
+ allow(other).to receive(:branch).and_return("different")
165
162
  expect(subject).to_not eq(other)
166
163
  end
167
164
 
168
- it 'returns false when the tag is different' do
169
- allow(other).to receive(:tag).and_return('different')
165
+ it "returns false when the tag is different" do
166
+ allow(other).to receive(:tag).and_return("different")
170
167
  expect(subject).to_not eq(other)
171
168
  end
172
169
 
173
- it 'returns false when the ref is different' do
174
- allow(other).to receive(:ref).and_return('different')
170
+ it "returns false when the ref is different" do
171
+ allow(other).to receive(:ref).and_return("different")
175
172
  expect(subject).to_not eq(other)
176
173
  end
177
174
 
178
- it 'returns false when the rel is different' do
179
- allow(other).to receive(:rel).and_return('different')
175
+ it "returns false when the rel is different" do
176
+ allow(other).to receive(:rel).and_return("different")
180
177
  expect(subject).to_not eq(other)
181
178
  end
182
179
  end
183
180
 
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)')
181
+ describe "#to_s" do
182
+ it "prefers the tag" do
183
+ expect(subject.to_s).to eq("https://repo.com (at v1.2.3/hi)")
187
184
  end
188
185
 
189
- it 'prefers the branch' do
186
+ it "prefers the branch" do
190
187
  allow(subject).to receive(:tag).and_return(nil)
191
- expect(subject.to_s).to eq('https://repo.com (at ham/hi)')
188
+ expect(subject.to_s).to eq("https://repo.com (at ham/hi)")
192
189
  end
193
190
 
194
- it 'falls back to the ref' do
191
+ it "falls back to the ref" do
195
192
  allow(subject).to receive(:tag).and_return(nil)
196
193
  allow(subject).to receive(:branch).and_return(nil)
197
- expect(subject.to_s).to eq('https://repo.com (at abc123/hi)')
194
+ expect(subject.to_s).to eq("https://repo.com (at abc123/hi)")
198
195
  end
199
196
 
200
- it 'does not use the rel if missing' do
197
+ it "does not use the rel if missing" do
201
198
  allow(subject).to receive(:rel).and_return(nil)
202
- expect(subject.to_s).to eq('https://repo.com (at v1.2.3)')
199
+ expect(subject.to_s).to eq("https://repo.com (at v1.2.3)")
203
200
  end
204
201
  end
205
202
 
206
- describe '#to_lock' do
207
- it 'includes all the information' do
208
- expect(subject.to_lock).to eq <<-EOH.gsub(/^ {8}/, '')
203
+ describe "#to_lock" do
204
+ it "includes all the information" do
205
+ expect(subject.to_lock).to eq <<-EOH.gsub(/^ {8}/, "")
209
206
  git: https://repo.com
210
207
  revision: defjkl123456
211
208
  ref: abc123
@@ -215,34 +212,34 @@ module Berkshelf
215
212
  EOH
216
213
  end
217
214
 
218
- it 'does not include the branch if missing' do
215
+ it "does not include the branch if missing" do
219
216
  allow(subject).to receive(:branch).and_return(nil)
220
- expect(subject.to_lock).to_not include('branch')
217
+ expect(subject.to_lock).to_not include("branch")
221
218
  end
222
219
 
223
- it 'does not include the tag if missing' do
220
+ it "does not include the tag if missing" do
224
221
  allow(subject).to receive(:tag).and_return(nil)
225
- expect(subject.to_lock).to_not include('tag')
222
+ expect(subject.to_lock).to_not include("tag")
226
223
  end
227
224
 
228
- it 'does not include the rel if missing' do
225
+ it "does not include the rel if missing" do
229
226
  allow(subject).to receive(:rel).and_return(nil)
230
- expect(subject.to_lock).to_not include('rel')
227
+ expect(subject.to_lock).to_not include("rel")
231
228
  end
232
229
  end
233
230
 
234
- describe '#git' do
231
+ describe "#git" do
235
232
  before { described_class.send(:public, :git) }
236
233
 
237
- it 'raises an error if Git is not installed' do
234
+ it "raises an error if Git is not installed" do
238
235
  allow(Berkshelf).to receive(:which).and_return(false)
239
- expect { subject.git('foo') }.to raise_error(GitNotInstalled)
236
+ expect { subject.git("foo") }.to raise_error(GitNotInstalled)
240
237
  end
241
238
 
242
- it 'raises an error if the command fails' do
243
- shell_out = double('shell_out', success?: false, stderr: nil)
244
- allow(Buff::ShellOut).to receive(:shell_out).and_return(shell_out)
245
- expect { subject.git('foo') }.to raise_error(GitCommandError)
239
+ it "raises an error if the command fails" do
240
+ shell_out = double("shell_out", error?: true, stderr: nil)
241
+ allow(subject).to receive(:shell_out).and_return(shell_out)
242
+ expect { subject.git("foo") }.to raise_error(GitCommandError)
246
243
  end
247
244
  end
248
245
  end
@@ -1,104 +1,103 @@
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,
12
- )
11
+ berksfile: berksfile)
13
12
  end
14
- let(:path) { fixtures_path.join('cookbooks', 'example_cookbook') }
15
- let(:relative_path) { Pathname.new('../../../fixtures/cookbooks/example_cookbook') }
13
+ let(:path) { fixtures_path.join("cookbooks", "example_cookbook") }
14
+ let(:relative_path) { Pathname.new("../../../fixtures/cookbooks/example_cookbook") }
16
15
 
17
16
  subject { described_class.new(dependency, path: path) }
18
17
 
19
- describe '#installed?' do
20
- it 'returns false' do
18
+ describe "#installed?" do
19
+ it "returns false" do
21
20
  expect(subject.installed?).to be(false)
22
21
  end
23
22
  end
24
23
 
25
- describe '#install' do
26
- it 'validates the cached cookbook' do
24
+ describe "#install" do
25
+ it "validates the cached cookbook" do
27
26
  expect(subject).to receive(:validate_cached!).with(path)
28
27
  subject.install
29
28
  end
30
29
  end
31
30
 
32
- describe '#cached_cookbook' do
33
- it 'loads the cached cookbook at the path' do
31
+ describe "#cached_cookbook" do
32
+ it "loads the cached cookbook at the path" do
34
33
  expect(CachedCookbook).to receive(:from_path).with(path)
35
34
  subject.cached_cookbook
36
35
  end
37
36
  end
38
37
 
39
- describe '#relative_path' do
40
- it 'returns the path to the Berksfile' do
38
+ describe "#relative_path" do
39
+ it "returns the path to the Berksfile" do
41
40
  expect(subject.relative_path).to eq(relative_path)
42
41
  end
43
42
  end
44
43
 
45
- describe '#expanded_path' do
46
- it 'returns the expanded path, relative to the Berksfile' do
44
+ describe "#expanded_path" do
45
+ it "returns the expanded path, relative to the Berksfile" do
47
46
  absolute_path = Pathname.new(File.expand_path(relative_path, File.dirname(berksfile.filepath)))
48
47
  expect(subject.expanded_path).to eq(absolute_path)
49
48
  end
50
49
  end
51
50
 
52
- describe '#==' do
53
- it 'is false when compared with a non-PathLocation' do
54
- this = PathLocation.new(dependency, path: '.')
55
- that = 'A string'
51
+ describe "#==" do
52
+ it "is false when compared with a non-PathLocation" do
53
+ this = PathLocation.new(dependency, path: ".")
54
+ that = "A string"
56
55
  expect(this).to_not eq(that)
57
56
  end
58
57
 
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)
58
+ it "is false when the metadata? is not the same" do
59
+ this = PathLocation.new(dependency, path: ".")
60
+ that = PathLocation.new(dependency, path: ".", metadata: true)
62
61
  expect(this).to_not eq(that)
63
62
  end
64
63
 
65
- it 'is false when the expanded paths are different' do
66
- this = PathLocation.new(dependency, path: '.')
67
- that = PathLocation.new(dependency, path: '..')
64
+ it "is false when the expanded paths are different" do
65
+ this = PathLocation.new(dependency, path: ".")
66
+ that = PathLocation.new(dependency, path: "..")
68
67
  expect(this).to_not eq(that)
69
68
  end
70
69
 
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)
70
+ it "is true when they are the same" do
71
+ this = PathLocation.new(dependency, path: ".", metadata: true)
72
+ that = PathLocation.new(dependency, path: ".", metadata: true)
74
73
  expect(this).to eq(that)
75
74
  end
76
75
  end
77
76
 
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}/, '')
77
+ describe "#to_lock" do
78
+ it "includes the path relative to the Berksfile" do
79
+ expect(subject.to_lock).to eq <<-EOH.gsub(/^ {10}/, "")
81
80
  path: #{relative_path}
82
81
  EOH
83
82
  end
84
83
 
85
- it 'includes the metadata attribute' do
84
+ it "includes the metadata attribute" do
86
85
  allow(subject).to receive(:metadata?).and_return(true)
87
- expect(subject.to_lock).to eq <<-EOH.gsub(/^ {10}/, '')
86
+ expect(subject.to_lock).to eq <<-EOH.gsub(/^ {10}/, "")
88
87
  path: #{relative_path}
89
88
  metadata: true
90
89
  EOH
91
90
  end
92
91
  end
93
92
 
94
- describe '#to_s' do
95
- it 'uses the relative path' do
93
+ describe "#to_s" do
94
+ it "uses the relative path" do
96
95
  expect(subject.to_s).to eq("source at #{relative_path}")
97
96
  end
98
97
  end
99
98
 
100
- describe '#inspect' do
101
- it 'includes the right information' do
99
+ describe "#inspect" do
100
+ it "includes the right information" do
102
101
  allow(subject).to receive(:metadata?).and_return(true)
103
102
  expect(subject.inspect).to eq("#<Berkshelf::PathLocation metadata: true, path: #{relative_path}>")
104
103
  end