cookbook-omnifetch 0.2.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- require 'cookbook-omnifetch/exceptions'
1
+ require "cookbook-omnifetch/exceptions"
2
2
 
3
3
  module CookbookOmnifetch
4
4
 
@@ -28,7 +28,6 @@ module CookbookOmnifetch
28
28
  value
29
29
  end
30
30
  end
31
-
32
31
  end
33
32
 
34
33
  configurable :cache_path
@@ -1,4 +1,4 @@
1
- require 'cookbook-omnifetch/base'
1
+ require "cookbook-omnifetch/base"
2
2
 
3
3
  module CookbookOmnifetch
4
4
  class PathLocation < BaseLocation
@@ -65,8 +65,8 @@ module CookbookOmnifetch
65
65
 
66
66
  def ==(other)
67
67
  other.is_a?(PathLocation) &&
68
- other.metadata? == metadata? &&
69
- other.relative_path == relative_path
68
+ other.metadata? == metadata? &&
69
+ other.relative_path == relative_path
70
70
  end
71
71
 
72
72
  def lock_data
@@ -1,3 +1,3 @@
1
1
  module CookbookOmnifetch
2
- VERSION = "0.2.3"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -1,3 +1,3 @@
1
- name 'example_cookbook'
2
- maintainer 'Berkshelf Core'
3
- version '0.5.0'
1
+ name "example_cookbook"
2
+ maintainer "Berkshelf Core"
3
+ version "0.5.0"
@@ -1,3 +1,3 @@
1
- name 'example_cookbook'
2
- maintainer 'Berkshelf Core'
3
- version '0.5.0'
1
+ name "example_cookbook"
2
+ maintainer "Berkshelf Core"
3
+ version "0.5.0"
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,9 @@
1
- require 'cookbook-omnifetch'
1
+ require "cookbook-omnifetch"
2
2
 
3
3
  module Fixtures
4
4
 
5
5
  def fixtures_path
6
- spec_root.join('fixtures')
6
+ spec_root.join("fixtures")
7
7
  end
8
8
 
9
9
  def spec_root
@@ -34,11 +34,10 @@ RSpec.configure do |config|
34
34
 
35
35
  config.before(:suite) do
36
36
  CookbookOmnifetch.configure do |c|
37
- c.cache_path = File.expand_path('~/.berkshelf')
38
- c.storage_path = Pathname.new(File.expand_path('~/.berkshelf/cookbooks'))
37
+ c.cache_path = File.expand_path("~/.berkshelf")
38
+ c.storage_path = Pathname.new(File.expand_path("~/.berkshelf/cookbooks"))
39
39
  c.shell_out_class = MockShellOut
40
40
  c.cached_cookbook_class = MockCachedCookbook
41
41
  end
42
42
  end
43
43
  end
44
-
@@ -1,5 +1,7 @@
1
- require 'spec_helper'
2
- require 'cookbook-omnifetch/artifactserver'
1
+ require "spec_helper"
2
+ require "cookbook-omnifetch/artifactserver"
3
+ require "zlib"
4
+ require "archive/tar/minitar"
3
5
 
4
6
  module CookbookOmnifetch
5
7
  describe ArtifactserverLocation do
@@ -14,7 +16,7 @@ module CookbookOmnifetch
14
16
 
15
17
  let(:url) { "https://supermarket.getchef.com/api/v1/cookbooks/nginx/versions/1.5.23/download" }
16
18
 
17
- let(:options) { {artifactserver: url, version: cookbook_version } }
19
+ let(:options) { { artifactserver: url, version: cookbook_version } }
18
20
 
19
21
  subject(:public_repo_location) { described_class.new(dependency, options) }
20
22
 
@@ -35,7 +37,7 @@ module CookbookOmnifetch
35
37
  end
36
38
 
37
39
  it "sets the install location as the cache path plus cache key" do
38
- expected_install_path = Pathname.new('~/.berkshelf/cookbooks').expand_path.join("nginx-1.5.23-supermarket.getchef.com")
40
+ expected_install_path = Pathname.new("~/.berkshelf/cookbooks").expand_path.join("nginx-1.5.23-supermarket.getchef.com")
39
41
  expect(public_repo_location.install_path).to eq(expected_install_path)
40
42
  end
41
43
 
@@ -52,7 +54,7 @@ module CookbookOmnifetch
52
54
  it "provides lock data as a Hash" do
53
55
  expected_data = {
54
56
  "artifactserver" => url,
55
- "version" => "1.5.23"
57
+ "version" => "1.5.23",
56
58
  }
57
59
  expect(public_repo_location.lock_data).to eq(expected_data)
58
60
  end
@@ -67,14 +69,14 @@ module CookbookOmnifetch
67
69
 
68
70
  let(:cache_path) { File.join(test_root, "cache") }
69
71
 
70
- let(:cookbook_fixtures_path) { fixtures_path.join('cookbooks') }
72
+ let(:cookbook_fixtures_path) { fixtures_path.join("cookbooks") }
71
73
 
72
74
  let(:cookbook_name) { "example_cookbook" }
73
75
 
74
76
  let(:cookbook_version) { "0.5.0" }
75
77
 
76
78
  let(:cookbook_tarball_handle) do
77
- gz_file_name = File.join(test_root, 'input.gz')
79
+ gz_file_name = File.join(test_root, "input.gz")
78
80
  Zlib::GzipWriter.open(gz_file_name) do |gz|
79
81
  # Minitar writes the full paths provided and doesn't seem to have a way to
80
82
  # remove prefixes. So we chdir like barbarians.
@@ -85,7 +87,7 @@ module CookbookOmnifetch
85
87
  File.open(gz_file_name)
86
88
  end
87
89
 
88
- let(:cookbook_files) { %w". .. .gitignore .kitchen.yml Berksfile Berksfile.lock metadata.rb README.md recipes" }
90
+ let(:cookbook_files) { %w{. .. .gitignore .kitchen.yml Berksfile Berksfile.lock metadata.rb README.md recipes} }
89
91
 
90
92
  before do
91
93
  allow(CookbookOmnifetch).to receive(:storage_path).and_return(Pathname.new(storage_path))
@@ -112,4 +114,3 @@ module CookbookOmnifetch
112
114
  end
113
115
  end
114
116
  end
115
-
@@ -1,59 +1,59 @@
1
- require 'spec_helper'
2
- require 'cookbook-omnifetch/base'
1
+ require "spec_helper"
2
+ require "cookbook-omnifetch/base"
3
3
 
4
4
  module CookbookOmnifetch
5
5
  describe BaseLocation do
6
- let(:constraint) { double('constraint') }
7
- let(:dependency) { double('dependency', name: 'cookbook', version_constraint: constraint) }
6
+ let(:constraint) { double("constraint") }
7
+ let(:dependency) { double("dependency", name: "cookbook", version_constraint: constraint) }
8
8
 
9
9
  subject { described_class.new(dependency) }
10
10
 
11
- describe '#installed?' do
12
- it 'is an abstract function' do
11
+ describe "#installed?" do
12
+ it "is an abstract function" do
13
13
  expect { subject.installed? }.to raise_error(AbstractFunction)
14
14
  end
15
15
  end
16
16
 
17
- describe '#install' do
18
- it 'is an abstract function' do
17
+ describe "#install" do
18
+ it "is an abstract function" do
19
19
  expect { subject.install }.to raise_error(AbstractFunction)
20
20
  end
21
21
  end
22
22
 
23
- describe '#cached_cookbook' do
24
- it 'is an abstract function' do
23
+ describe "#cached_cookbook" do
24
+ it "is an abstract function" do
25
25
  expect { subject.cached_cookbook }.to raise_error(AbstractFunction)
26
26
  end
27
27
  end
28
28
 
29
- describe '#to_lock' do
30
- it 'is an abstract function' do
29
+ describe "#to_lock" do
30
+ it "is an abstract function" do
31
31
  expect { subject.to_lock }.to raise_error(AbstractFunction)
32
32
  end
33
33
  end
34
34
 
35
- describe '#lock_data' do
36
- it 'is an abstract function' do
35
+ describe "#lock_data" do
36
+ it "is an abstract function" do
37
37
  expect { subject.lock_data }.to raise_error(AbstractFunction)
38
38
  end
39
39
  end
40
40
 
41
- describe '#validate_cached!' do
42
- context 'when the path is not a cookbook' do
41
+ describe "#validate_cached!" do
42
+ context "when the path is not a cookbook" do
43
43
  before { CookbookOmnifetch.stub(:cookbook?).and_return(false) }
44
44
 
45
- it 'raises an error' do
46
- expect {
47
- subject.validate_cached!('/foo/bar')
48
- }.to raise_error(NotACookbook)
45
+ it "raises an error" do
46
+ expect do
47
+ subject.validate_cached!("/foo/bar")
48
+ end.to raise_error(NotACookbook)
49
49
  end
50
50
  end
51
51
 
52
- context 'when the path is a cookbook' do
52
+ context "when the path is a cookbook" do
53
53
  let(:cookbook) do
54
- double('cookbook',
55
- cookbook_name: 'cookbook',
56
- version: '0.1.0',
54
+ double("cookbook",
55
+ cookbook_name: "cookbook",
56
+ version: "0.1.0"
57
57
  )
58
58
  end
59
59
 
@@ -62,23 +62,23 @@ module CookbookOmnifetch
62
62
  MockCachedCookbook.stub(:from_path).and_return(cookbook)
63
63
  end
64
64
 
65
- it 'raises an error if the constraint does not satisfy' do
66
- constraint.stub(:satisfies?).with('0.1.0').and_return(false)
67
- expect {
65
+ it "raises an error if the constraint does not satisfy" do
66
+ constraint.stub(:satisfies?).with("0.1.0").and_return(false)
67
+ expect do
68
68
  subject.validate_cached!(cookbook)
69
- }.to raise_error(CookbookValidationFailure)
69
+ end.to raise_error(CookbookValidationFailure)
70
70
  end
71
71
 
72
- it 'raises an error if the names do not match' do
73
- constraint.stub(:satisfies?).with('0.1.0').and_return(true)
74
- cookbook.stub(:cookbook_name).and_return('different_name')
75
- expect {
72
+ it "raises an error if the names do not match" do
73
+ constraint.stub(:satisfies?).with("0.1.0").and_return(true)
74
+ cookbook.stub(:cookbook_name).and_return("different_name")
75
+ expect do
76
76
  subject.validate_cached!(cookbook)
77
- }.to raise_error(MismatchedCookbookName)
77
+ end.to raise_error(MismatchedCookbookName)
78
78
  end
79
79
 
80
- it 'returns true when the validation succeeds' do
81
- constraint.stub(:satisfies?).with('0.1.0').and_return(true)
80
+ it "returns true when the validation succeeds" do
81
+ constraint.stub(:satisfies?).with("0.1.0").and_return(true)
82
82
  expect(subject.validate_cached!(cookbook)).to be true
83
83
  end
84
84
  end
@@ -0,0 +1,75 @@
1
+ require "spec_helper"
2
+ require "cookbook-omnifetch/chef_server.rb"
3
+
4
+ module CookbookOmnifetch
5
+ METADATA = {
6
+ "recipes" => [
7
+ { "name" => "default.rb", "path" => "recipes/default.rb", "checksum" => "a6be794cdd2eb44d38fdf17f792a0d0d", "specificity" => "default", "url" => "https://example.com/recipes/default.rb" },
8
+ ],
9
+ "root_files" => [
10
+ { "name" => "metadata.rb", "path" => "metadata.rb", "checksum" => "5b346119e5e41ab99500608decac8dca", "specificity" => "default", "url" => "https://example.com/metadata.rb" },
11
+ ],
12
+ }
13
+
14
+ describe CookbookMetadata do
15
+ let(:cb_metadata) { CookbookMetadata.new(METADATA) }
16
+
17
+ it "yields a set of paths and urls" do
18
+ expect { |b| cb_metadata.files(&b) }.to yield_successive_args(["https://example.com/recipes/default.rb", "recipes/default.rb"], ["https://example.com/metadata.rb", "metadata.rb"])
19
+ end
20
+ end
21
+
22
+ describe ChefserverLocation do
23
+
24
+ let(:http_client) { double("Http Client") }
25
+
26
+ let(:cb_metadata) { CookbookMetadata.new(METADATA) }
27
+
28
+ let(:test_root) { Dir.mktmpdir(nil) }
29
+
30
+ let(:storage_path) { File.join(test_root, "storage") }
31
+
32
+ let(:cache_path) { File.join(test_root, "cache") }
33
+
34
+ let(:constraint) { double("Constraint") }
35
+
36
+ let(:dependency) { double("Dependency", name: cookbook_name, constraint: constraint) }
37
+
38
+ let(:cookbook_name) { "example" }
39
+ let(:cookbook_version) { "0.5.0" }
40
+
41
+ let(:cookbook_fixture_path) { fixtures_path.join("cookbooks/example_cookbook") }
42
+
43
+ let(:remote_path) { File.join(test_root, "remote") }
44
+ let(:options) { { version: cookbook_version, http_client: http_client } }
45
+
46
+ let(:cookbook_files) { %w{. .. metadata.rb recipes} }
47
+ subject(:chef_server_location) { described_class.new(dependency, options) }
48
+
49
+ before do
50
+ allow(CookbookOmnifetch).to receive(:storage_path).and_return(Pathname.new(storage_path))
51
+ allow(CookbookOmnifetch).to receive(:cache_path).and_return(cache_path)
52
+ allow_any_instance_of(File).to receive(:close).and_return(true)
53
+ FileUtils.cp_r(cookbook_fixture_path, remote_path)
54
+ FileUtils.mkdir_p(storage_path)
55
+ end
56
+
57
+ after do
58
+ FileUtils.rm_r(test_root)
59
+ end
60
+
61
+ it "installs the cookbook to the desired install path" do
62
+ expect(http_client).to receive(:get).with("/cookbooks/example/0.5.0").and_return(METADATA)
63
+ expect(http_client).to receive(:streaming_request).twice do |url, &block|
64
+ path = url.split("/", 4)[3]
65
+ path = File.join(remote_path, path)
66
+ block.call(File.open(path))
67
+ end
68
+
69
+ chef_server_location.install
70
+
71
+ expect(Dir).to exist(chef_server_location.install_path)
72
+ expect(Dir.entries(chef_server_location.install_path)).to match_array(cookbook_files)
73
+ end
74
+ end
75
+ end
@@ -1,5 +1,5 @@
1
- require 'spec_helper'
2
- require 'cookbook-omnifetch/exceptions'
1
+ require "spec_helper"
2
+ require "cookbook-omnifetch/exceptions"
3
3
 
4
4
  module CookbookOmnifetch
5
5
  describe "Exceptions" do
@@ -1,77 +1,77 @@
1
- require 'spec_helper'
2
- require 'cookbook-omnifetch/git'
1
+ require "spec_helper"
2
+ require "cookbook-omnifetch/git"
3
3
 
4
4
  module CookbookOmnifetch
5
5
  describe GitLocation do
6
- let(:dependency) { double(name: 'bacon') }
6
+ let(:dependency) { double(name: "bacon") }
7
7
 
8
8
  subject do
9
- described_class.new(dependency, git: 'https://repo.com', branch: 'ham',
10
- tag: 'v1.2.3', ref: 'abc123', revision: 'defjkl123456', rel: 'hi')
9
+ described_class.new(dependency, git: "https://repo.com", branch: "ham",
10
+ tag: "v1.2.3", ref: "abc123", revision: "defjkl123456", rel: "hi")
11
11
  end
12
12
 
13
- describe '.initialize' do
14
- it 'sets the uri' do
15
- instance = described_class.new(dependency, git: 'https://repo.com')
16
- expect(instance.uri).to eq('https://repo.com')
13
+ describe ".initialize" do
14
+ it "sets the uri" do
15
+ instance = described_class.new(dependency, git: "https://repo.com")
16
+ expect(instance.uri).to eq("https://repo.com")
17
17
  end
18
18
 
19
- it 'sets the branch' do
19
+ it "sets the branch" do
20
20
  instance = described_class.new(dependency,
21
- git: 'https://repo.com', branch: 'magic_new_feature')
22
- expect(instance.branch).to eq('magic_new_feature')
21
+ git: "https://repo.com", branch: "magic_new_feature")
22
+ expect(instance.branch).to eq("magic_new_feature")
23
23
  end
24
24
 
25
- it 'sets the tag' do
25
+ it "sets the tag" do
26
26
  instance = described_class.new(dependency,
27
- git: 'https://repo.com', tag: 'v1.2.3')
28
- expect(instance.tag).to eq('v1.2.3')
27
+ git: "https://repo.com", tag: "v1.2.3")
28
+ expect(instance.tag).to eq("v1.2.3")
29
29
  end
30
30
 
31
- it 'adds the ref' do
31
+ it "adds the ref" do
32
32
  instance = described_class.new(dependency,
33
- git: 'https://repo.com', ref: 'abc123')
34
- expect(instance.ref).to eq('abc123')
33
+ git: "https://repo.com", ref: "abc123")
34
+ expect(instance.ref).to eq("abc123")
35
35
  end
36
36
 
37
- it 'sets the revision' do
37
+ it "sets the revision" do
38
38
  instance = described_class.new(dependency,
39
- git: 'https://repo.com', revision: 'abcde12345')
40
- expect(instance.revision).to eq('abcde12345')
39
+ git: "https://repo.com", revision: "abcde12345")
40
+ expect(instance.revision).to eq("abcde12345")
41
41
  end
42
42
 
43
- it 'sets the rel' do
43
+ it "sets the rel" do
44
44
  instance = described_class.new(dependency,
45
- git: 'https://repo.com', rel: 'internal/path')
46
- expect(instance.rel).to eq('internal/path')
45
+ git: "https://repo.com", rel: "internal/path")
46
+ expect(instance.rel).to eq("internal/path")
47
47
  end
48
48
 
49
- context 'rev_parse' do
49
+ context "rev_parse" do
50
50
  def rev_parse(instance)
51
51
  instance.instance_variable_get(:@rev_parse)
52
52
  end
53
53
 
54
- it 'uses the :ref option with priority' do
54
+ it "uses the :ref option with priority" do
55
55
  instance = described_class.new(dependency,
56
- git: 'https://repo.com', ref: 'abc123', branch: 'magic_new_feature')
57
- expect(rev_parse(instance)).to eq('abc123')
56
+ git: "https://repo.com", ref: "abc123", branch: "magic_new_feature")
57
+ expect(rev_parse(instance)).to eq("abc123")
58
58
  end
59
59
 
60
- it 'uses the :branch option with priority' do
60
+ it "uses the :branch option with priority" do
61
61
  instance = described_class.new(dependency,
62
- git: 'https://repo.com', branch: 'magic_new_feature', tag: 'v1.2.3')
63
- expect(rev_parse(instance)).to eq('magic_new_feature')
62
+ git: "https://repo.com", branch: "magic_new_feature", tag: "v1.2.3")
63
+ expect(rev_parse(instance)).to eq("magic_new_feature")
64
64
  end
65
65
 
66
- it 'uses the :tag option' do
66
+ it "uses the :tag option" do
67
67
  instance = described_class.new(dependency,
68
- git: 'https://repo.com', tag: 'v1.2.3')
69
- expect(rev_parse(instance)).to eq('v1.2.3')
68
+ git: "https://repo.com", tag: "v1.2.3")
69
+ expect(rev_parse(instance)).to eq("v1.2.3")
70
70
  end
71
71
 
72
72
  it 'uses "master" when none is given' do
73
- instance = described_class.new(dependency, git: 'https://repo.com')
74
- expect(rev_parse(instance)).to eq('master')
73
+ instance = described_class.new(dependency, git: "https://repo.com")
74
+ expect(rev_parse(instance)).to eq("master")
75
75
  end
76
76
  end
77
77
  end
@@ -84,26 +84,26 @@ module CookbookOmnifetch
84
84
  end
85
85
  end
86
86
 
87
- describe '#installed?' do
88
- it 'returns false when there is no revision' do
87
+ describe "#installed?" do
88
+ it "returns false when there is no revision" do
89
89
  subject.stub(:revision).and_return(nil)
90
90
  expect(subject.installed?).to be false
91
91
  end
92
92
 
93
- it 'returns false when the install_path does not exist' do
94
- subject.stub(:revision).and_return('abcd1234')
93
+ it "returns false when the install_path does not exist" do
94
+ subject.stub(:revision).and_return("abcd1234")
95
95
  subject.stub(:install_path).and_return(double(exist?: false))
96
96
  expect(subject.installed?).to be false
97
97
  end
98
98
 
99
- it 'returns true when the location is installed' do
100
- subject.stub(:revision).and_return('abcd1234')
99
+ it "returns true when the location is installed" do
100
+ subject.stub(:revision).and_return("abcd1234")
101
101
  subject.stub(:install_path).and_return(double(exist?: true))
102
102
  expect(subject.installed?).to be true
103
103
  end
104
104
  end
105
105
 
106
- describe '#install' do
106
+ describe "#install" do
107
107
  before do
108
108
  File.stub(:chmod)
109
109
  FileUtils.stub(:cp_r)
@@ -111,8 +111,8 @@ module CookbookOmnifetch
111
111
  subject.stub(:git)
112
112
  end
113
113
 
114
- context 'when the repository is cached' do
115
- it 'pulls a new version' do
114
+ context "when the repository is cached" do
115
+ it "pulls a new version" do
116
116
  Dir.stub(:chdir) { |args, &b| b.call } # Force eval the chdir block
117
117
 
118
118
  subject.stub(:cached?).and_return(true)
@@ -123,27 +123,27 @@ module CookbookOmnifetch
123
123
  end
124
124
  end
125
125
 
126
- context 'when the revision is not cached' do
127
- it 'clones the repository' do
126
+ context "when the revision is not cached" do
127
+ it "clones the repository" do
128
128
  Dir.stub(:chdir) { |args, &b| b.call } # Force eval the chdir block
129
129
 
130
130
  cache_path = subject.send(:cache_path)
131
131
  subject.stub(:cached?).and_return(false)
132
132
  expect(subject).to receive(:git).with(
133
- %|clone https://repo.com "#{cache_path}" --bare --no-hardlinks|
133
+ %{clone https://repo.com "#{cache_path}" --bare --no-hardlinks}
134
134
  )
135
135
  subject.install
136
136
  end
137
137
  end
138
138
  end
139
139
 
140
- describe '#cached_cookbook' do
141
- it 'returns nil if the cookbook is not installed' do
140
+ describe "#cached_cookbook" do
141
+ it "returns nil if the cookbook is not installed" do
142
142
  subject.stub(:installed?).and_return(false)
143
143
  expect(subject.cached_cookbook).to be_nil
144
144
  end
145
145
 
146
- it 'returns the cookbook at the install_path' do
146
+ it "returns the cookbook at the install_path" do
147
147
  subject.stub(:installed?).and_return(true)
148
148
  MockCachedCookbook.stub(:from_path)
149
149
 
@@ -152,69 +152,69 @@ module CookbookOmnifetch
152
152
  end
153
153
  end
154
154
 
155
- describe '#==' do
155
+ describe "#==" do
156
156
  let(:other) { subject.dup }
157
157
 
158
- it 'returns true when everything matches' do
158
+ it "returns true when everything matches" do
159
159
  expect(subject).to eq(other)
160
160
  end
161
161
 
162
- it 'returns false when the other location is not an GitLocation' do
162
+ it "returns false when the other location is not an GitLocation" do
163
163
  other.stub(:is_a?).and_return(false)
164
164
  expect(subject).to_not eq(other)
165
165
  end
166
166
 
167
- it 'returns false when the uri is different' do
168
- other.stub(:uri).and_return('different')
167
+ it "returns false when the uri is different" do
168
+ other.stub(:uri).and_return("different")
169
169
  expect(subject).to_not eq(other)
170
170
  end
171
171
 
172
- it 'returns false when the branch is different' do
173
- other.stub(:branch).and_return('different')
172
+ it "returns false when the branch is different" do
173
+ other.stub(:branch).and_return("different")
174
174
  expect(subject).to_not eq(other)
175
175
  end
176
176
 
177
- it 'returns false when the tag is different' do
178
- other.stub(:tag).and_return('different')
177
+ it "returns false when the tag is different" do
178
+ other.stub(:tag).and_return("different")
179
179
  expect(subject).to_not eq(other)
180
180
  end
181
181
 
182
- it 'returns false when the ref is different' do
183
- other.stub(:ref).and_return('different')
182
+ it "returns false when the ref is different" do
183
+ other.stub(:ref).and_return("different")
184
184
  expect(subject).to_not eq(other)
185
185
  end
186
186
 
187
- it 'returns false when the rel is different' do
188
- other.stub(:rel).and_return('different')
187
+ it "returns false when the rel is different" do
188
+ other.stub(:rel).and_return("different")
189
189
  expect(subject).to_not eq(other)
190
190
  end
191
191
  end
192
192
 
193
- describe '#to_s' do
194
- it 'prefers the tag' do
195
- expect(subject.to_s).to eq('https://repo.com (at v1.2.3/hi)')
193
+ describe "#to_s" do
194
+ it "prefers the tag" do
195
+ expect(subject.to_s).to eq("https://repo.com (at v1.2.3/hi)")
196
196
  end
197
197
 
198
- it 'prefers the branch' do
198
+ it "prefers the branch" do
199
199
  subject.stub(:tag).and_return(nil)
200
- expect(subject.to_s).to eq('https://repo.com (at ham/hi)')
200
+ expect(subject.to_s).to eq("https://repo.com (at ham/hi)")
201
201
  end
202
202
 
203
- it 'falls back to the ref' do
203
+ it "falls back to the ref" do
204
204
  subject.stub(:tag).and_return(nil)
205
205
  subject.stub(:branch).and_return(nil)
206
- expect(subject.to_s).to eq('https://repo.com (at abc123/hi)')
206
+ expect(subject.to_s).to eq("https://repo.com (at abc123/hi)")
207
207
  end
208
208
 
209
- it 'does not use the rel if missing' do
209
+ it "does not use the rel if missing" do
210
210
  subject.stub(:rel).and_return(nil)
211
- expect(subject.to_s).to eq('https://repo.com (at v1.2.3)')
211
+ expect(subject.to_s).to eq("https://repo.com (at v1.2.3)")
212
212
  end
213
213
  end
214
214
 
215
- describe '#to_lock' do
216
- it 'includes all the information' do
217
- expect(subject.to_lock).to eq <<-EOH.gsub(/^ {8}/, '')
215
+ describe "#to_lock" do
216
+ it "includes all the information" do
217
+ expect(subject.to_lock).to eq <<-EOH.gsub(/^ {8}/, "")
218
218
  git: https://repo.com
219
219
  revision: defjkl123456
220
220
  ref: abc123
@@ -224,23 +224,23 @@ module CookbookOmnifetch
224
224
  EOH
225
225
  end
226
226
 
227
- it 'does not include the branch if missing' do
227
+ it "does not include the branch if missing" do
228
228
  subject.stub(:branch).and_return(nil)
229
- expect(subject.to_lock).to_not include('branch')
229
+ expect(subject.to_lock).to_not include("branch")
230
230
  end
231
231
 
232
- it 'does not include the tag if missing' do
232
+ it "does not include the tag if missing" do
233
233
  subject.stub(:tag).and_return(nil)
234
- expect(subject.to_lock).to_not include('tag')
234
+ expect(subject.to_lock).to_not include("tag")
235
235
  end
236
236
 
237
- it 'does not include the rel if missing' do
237
+ it "does not include the rel if missing" do
238
238
  subject.stub(:rel).and_return(nil)
239
- expect(subject.to_lock).to_not include('rel')
239
+ expect(subject.to_lock).to_not include("rel")
240
240
  end
241
241
  end
242
242
 
243
- describe '#lock_data' do
243
+ describe "#lock_data" do
244
244
  let(:full_lock_data) do
245
245
  {
246
246
  "git" => "https://repo.com",
@@ -248,43 +248,42 @@ module CookbookOmnifetch
248
248
  "ref" => "abc123",
249
249
  "branch" => "ham",
250
250
  "tag" => "v1.2.3",
251
- "rel" => "hi"
251
+ "rel" => "hi",
252
252
  }
253
253
  end
254
254
 
255
- it 'includes all the information' do
255
+ it "includes all the information" do
256
256
  expect(subject.lock_data).to eq(full_lock_data)
257
257
  end
258
258
 
259
- it 'does not include the branch if missing' do
259
+ it "does not include the branch if missing" do
260
260
  subject.stub(:branch).and_return(nil)
261
- expect(subject.lock_data).to_not have_key('branch')
261
+ expect(subject.lock_data).to_not have_key("branch")
262
262
  end
263
263
 
264
- it 'does not include the tag if missing' do
264
+ it "does not include the tag if missing" do
265
265
  subject.stub(:tag).and_return(nil)
266
- expect(subject.lock_data).to_not have_key('tag')
266
+ expect(subject.lock_data).to_not have_key("tag")
267
267
  end
268
268
 
269
- it 'does not include the rel if missing' do
269
+ it "does not include the rel if missing" do
270
270
  subject.stub(:rel).and_return(nil)
271
- expect(subject.lock_data).to_not have_key('rel')
271
+ expect(subject.lock_data).to_not have_key("rel")
272
272
  end
273
273
  end
274
274
 
275
-
276
- describe '#git' do
275
+ describe "#git" do
277
276
  before { described_class.send(:public, :git) }
278
277
 
279
- it 'raises an error if Git is not installed' do
278
+ it "raises an error if Git is not installed" do
280
279
  CookbookOmnifetch.stub(:which).and_return(false)
281
- expect { subject.git('foo') }.to raise_error(GitNotInstalled)
280
+ expect { subject.git("foo") }.to raise_error(GitNotInstalled)
282
281
  end
283
282
 
284
- it 'raises an error if the command fails' do
285
- shell_out = double('shell_out', success?: false, stderr: nil)
283
+ it "raises an error if the command fails" do
284
+ shell_out = double("shell_out", success?: false, stderr: nil)
286
285
  MockShellOut.stub(:shell_out).and_return(shell_out)
287
- expect { subject.git('foo') }.to raise_error(GitCommandError)
286
+ expect { subject.git("foo") }.to raise_error(GitCommandError)
288
287
  end
289
288
  end
290
289
  end