cookbook-omnifetch 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,119 +0,0 @@
1
- require "spec_helper"
2
- require "cookbook-omnifetch/path"
3
-
4
- module CookbookOmnifetch
5
- describe PathLocation do
6
- let(:relative_paths_root) { File.dirname(__FILE__) }
7
- let(:constraint) { double("constraint", satisfies?: true) }
8
- let(:dependency) do
9
- double("dependency",
10
- name: "nginx",
11
- version_constraint: constraint,
12
- relative_paths_root: relative_paths_root
13
- )
14
- end
15
- let(:path) { fixtures_path.join("cookbooks", "example_cookbook") }
16
- let(:relative_path) { Pathname.new("../fixtures/cookbooks/example_cookbook") }
17
-
18
- subject { described_class.new(dependency, path: path) }
19
-
20
- describe "#installed?" do
21
- it "returns false" do
22
- expect(subject.installed?).to be false
23
- end
24
- end
25
-
26
- describe "#install" do
27
- it "validates the cached cookbook" do
28
- expect(subject).to receive(:validate_cached!).with(path)
29
- subject.install
30
- end
31
- end
32
-
33
- describe "#cached_cookbook" do
34
- it "loads the cached cookbook at the path" do
35
- expect(MockCachedCookbook).to receive(:from_path).with(path)
36
- subject.cached_cookbook
37
- end
38
- end
39
-
40
- describe "#relative_path" do
41
- it "returns the path to the Berksfile" do
42
- expect(subject.relative_path).to eq(relative_path)
43
- end
44
- end
45
-
46
- describe "#expanded_path" do
47
- it "returns the expanded path, relative to the Berksfile" do
48
- absolute_path = Pathname.new(File.expand_path(relative_path, relative_paths_root))
49
- expect(subject.expanded_path).to eq(absolute_path)
50
- end
51
- end
52
-
53
- describe "#==" do
54
- it "is false when compared with a non-PathLocation" do
55
- this = PathLocation.new(dependency, path: ".")
56
- that = "A string"
57
- expect(this).to_not eq(that)
58
- end
59
-
60
- it "is false when the metadata? is not the same" do
61
- this = PathLocation.new(dependency, path: ".")
62
- that = PathLocation.new(dependency, path: ".", metadata: true)
63
- expect(this).to_not eq(that)
64
- end
65
-
66
- it "is false when the expanded paths are different" do
67
- this = PathLocation.new(dependency, path: ".")
68
- that = PathLocation.new(dependency, path: "..")
69
- expect(this).to_not eq(that)
70
- end
71
-
72
- it "is true when they are the same" do
73
- this = PathLocation.new(dependency, path: ".", metadata: true)
74
- that = PathLocation.new(dependency, path: ".", metadata: true)
75
- expect(this).to eq(that)
76
- end
77
- end
78
-
79
- describe "#to_lock" do
80
- it "includes the path relative to the Berksfile" do
81
- expect(subject.to_lock).to eq <<-EOH.gsub(/^ {10}/, "")
82
- path: #{relative_path}
83
- EOH
84
- end
85
-
86
- it "includes the metadata attribute" do
87
- subject.stub(:metadata?).and_return(true)
88
- expect(subject.to_lock).to eq <<-EOH.gsub(/^ {10}/, "")
89
- path: #{relative_path}
90
- metadata: true
91
- EOH
92
- end
93
- end
94
-
95
- describe "#lock_data" do
96
- it "includes the path relative to the Berksfile" do
97
- expect(subject.lock_data).to eq({ "path" => relative_path.to_s })
98
- end
99
-
100
- it "includes the metadata attribute" do
101
- subject.stub(:metadata?).and_return(true)
102
- expect(subject.lock_data).to eq({ "path" => relative_path.to_s, "metadata" => true })
103
- end
104
- end
105
-
106
- describe "#to_s" do
107
- it "uses the relative path" do
108
- expect(subject.to_s).to eq("source at #{relative_path}")
109
- end
110
- end
111
-
112
- describe "#inspect" do
113
- it "includes the right information" do
114
- subject.stub(:metadata?).and_return(true)
115
- expect(subject.inspect).to eq("#<CookbookOmnifetch::PathLocation metadata: true, path: #{relative_path}>")
116
- end
117
- end
118
- end
119
- end