ridley 4.2.0 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -1
- data/README.md +4 -4
- data/lib/ridley/connection.rb +1 -2
- data/lib/ridley/errors.rb +1 -0
- data/lib/ridley/mixin/params_validate.rb +4 -0
- data/lib/ridley/version.rb +1 -1
- data/ridley.gemspec +2 -2
- data/spec/acceptance/client_resource_spec.rb +12 -12
- data/spec/acceptance/cookbook_resource_spec.rb +15 -15
- data/spec/acceptance/data_bag_item_resource_spec.rb +14 -14
- data/spec/acceptance/data_bag_resource_spec.rb +4 -4
- data/spec/acceptance/environment_resource_spec.rb +14 -14
- data/spec/acceptance/node_resource_spec.rb +15 -15
- data/spec/acceptance/role_resource_spec.rb +14 -14
- data/spec/acceptance/sandbox_resource_spec.rb +3 -3
- data/spec/acceptance/search_resource_spec.rb +6 -6
- data/spec/acceptance/user_resource_spec.rb +21 -21
- data/spec/support/each_matcher.rb +2 -2
- data/spec/support/filepath_matchers.rb +2 -2
- data/spec/support/shared_examples/ridley_resource.rb +39 -39
- data/spec/unit/ridley/chef/cookbook/metadata_spec.rb +8 -8
- data/spec/unit/ridley/chef/cookbook/syntax_check_spec.rb +15 -15
- data/spec/unit/ridley/chef/cookbook_spec.rb +124 -118
- data/spec/unit/ridley/chef/digester_spec.rb +2 -2
- data/spec/unit/ridley/chef_object_spec.rb +35 -35
- data/spec/unit/ridley/chef_objects/client_object_spec.rb +2 -2
- data/spec/unit/ridley/chef_objects/cookbook_object_spec.rb +12 -12
- data/spec/unit/ridley/chef_objects/data_bag_item_object_spec.rb +7 -7
- data/spec/unit/ridley/chef_objects/data_bag_object_spec.rb +4 -1
- data/spec/unit/ridley/chef_objects/environment_object_spec.rb +10 -10
- data/spec/unit/ridley/chef_objects/node_object_spec.rb +28 -28
- data/spec/unit/ridley/chef_objects/role_object_spec.rb +10 -10
- data/spec/unit/ridley/chef_objects/sandbox_object_spec.rb +6 -6
- data/spec/unit/ridley/client_spec.rb +59 -21
- data/spec/unit/ridley/connection_spec.rb +7 -7
- data/spec/unit/ridley/errors_spec.rb +3 -3
- data/spec/unit/ridley/middleware/chef_auth_spec.rb +2 -2
- data/spec/unit/ridley/middleware/chef_response_spec.rb +29 -29
- data/spec/unit/ridley/middleware/parse_json_spec.rb +14 -14
- data/spec/unit/ridley/mixins/from_file_spec.rb +3 -3
- data/spec/unit/ridley/resource_spec.rb +5 -5
- data/spec/unit/ridley/resources/cookbook_resource_spec.rb +10 -10
- data/spec/unit/ridley/resources/data_bag_item_resource_spec.rb +1 -1
- data/spec/unit/ridley/resources/data_bag_resource_spec.rb +6 -3
- data/spec/unit/ridley/resources/environment_resource_spec.rb +4 -4
- data/spec/unit/ridley/resources/role_resource_spec.rb +1 -1
- data/spec/unit/ridley/resources/sandbox_resource_spec.rb +7 -7
- data/spec/unit/ridley/resources/search_resource_spec.rb +22 -22
- data/spec/unit/ridley/sandbox_uploader_spec.rb +3 -3
- data/spec/unit/ridley_spec.rb +6 -6
- metadata +15 -18
- data/lib/ridley/middleware/gzip.rb +0 -18
- data/spec/unit/ridley/middleware/gzip_spec.rb +0 -59
@@ -9,14 +9,14 @@ describe Ridley::Chef::Digester do
|
|
9
9
|
|
10
10
|
describe "when computing checksums of cookbook files and templates" do
|
11
11
|
it "proxies the class method checksum_for_file to the instance" do
|
12
|
-
@cache.
|
12
|
+
expect(@cache).to receive(:checksum_for_file).with("a_file_or_a_fail")
|
13
13
|
described_class.checksum_for_file("a_file_or_a_fail")
|
14
14
|
end
|
15
15
|
|
16
16
|
it "generates a checksum from a non-file IO object" do
|
17
17
|
io = StringIO.new("riseofthemachines\nriseofthechefs\n")
|
18
18
|
expected_md5 = '0e157ac1e2dd73191b76067fb6b4bceb'
|
19
|
-
@cache.generate_md5_checksum(io).
|
19
|
+
expect(@cache.generate_md5_checksum(io)).to eq(expected_md5)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -10,7 +10,7 @@ describe Ridley::ChefObject do
|
|
10
10
|
name: "a name"
|
11
11
|
}
|
12
12
|
|
13
|
-
subject.
|
13
|
+
expect_any_instance_of(subject).to receive(:mass_assign).with(new_attrs)
|
14
14
|
subject.new(resource, new_attrs)
|
15
15
|
end
|
16
16
|
end
|
@@ -19,7 +19,7 @@ describe Ridley::ChefObject do
|
|
19
19
|
it "sets the chef_type attr on the class" do
|
20
20
|
subject.set_chef_type("environment")
|
21
21
|
|
22
|
-
subject.chef_type.
|
22
|
+
expect(subject.chef_type).to eql("environment")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -27,7 +27,7 @@ describe Ridley::ChefObject do
|
|
27
27
|
it "sets the chef_json_class attr on the class" do
|
28
28
|
subject.set_chef_json_class("Chef::Environment")
|
29
29
|
|
30
|
-
subject.chef_json_class.
|
30
|
+
expect(subject.chef_json_class).to eql("Chef::Environment")
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -35,25 +35,25 @@ describe Ridley::ChefObject do
|
|
35
35
|
it "sets the chef_id attribute on the class" do
|
36
36
|
subject.set_chef_id(:environment)
|
37
37
|
|
38
|
-
subject.chef_id.
|
38
|
+
expect(subject.chef_id).to eql(:environment)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "::chef_type" do
|
43
43
|
it "returns the underscored name of the including class if nothing is set" do
|
44
|
-
subject.chef_type.
|
44
|
+
expect(subject.chef_type).to eql(subject.class.name.underscore)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "::chef_json_class" do
|
49
49
|
it "returns the chef_json if nothing has been set" do
|
50
|
-
subject.chef_json_class.
|
50
|
+
expect(subject.chef_json_class).to be_nil
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
describe "::chef_id" do
|
55
55
|
it "returns nil if nothing is set" do
|
56
|
-
subject.chef_id.
|
56
|
+
expect(subject.chef_id).to be_nil
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -64,12 +64,12 @@ describe Ridley::ChefObject do
|
|
64
64
|
|
65
65
|
describe "#save" do
|
66
66
|
context "when the object is valid" do
|
67
|
-
before(:each) { subject.
|
67
|
+
before(:each) { allow(subject).to receive(:valid?).and_return(true) }
|
68
68
|
|
69
69
|
it "sends a create message to the implementing class" do
|
70
70
|
updated = double('updated')
|
71
|
-
updated.
|
72
|
-
resource.
|
71
|
+
allow(updated).to receive(:_attributes_).and_return(Hash.new)
|
72
|
+
expect(resource).to receive(:create).with(subject).and_return(updated)
|
73
73
|
|
74
74
|
subject.save
|
75
75
|
end
|
@@ -77,10 +77,10 @@ describe Ridley::ChefObject do
|
|
77
77
|
context "when there is an HTTPConflict" do
|
78
78
|
it "sends the update message to self" do
|
79
79
|
updated = double('updated')
|
80
|
-
updated.
|
81
|
-
updated.
|
82
|
-
resource.
|
83
|
-
subject.
|
80
|
+
allow(updated).to receive(:[]).and_return(Hash.new)
|
81
|
+
allow(updated).to receive(:_attributes_).and_return(Hash.new)
|
82
|
+
expect(resource).to receive(:create).and_raise(Ridley::Errors::HTTPConflict.new(updated))
|
83
|
+
expect(subject).to receive(:update).and_return(updated)
|
84
84
|
|
85
85
|
subject.save
|
86
86
|
end
|
@@ -88,12 +88,12 @@ describe Ridley::ChefObject do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
context "when the object is invalid" do
|
91
|
-
before(:each) { subject.
|
91
|
+
before(:each) { allow(subject).to receive(:valid?).and_return(false) }
|
92
92
|
|
93
93
|
it "raises an InvalidResource error" do
|
94
|
-
|
94
|
+
expect {
|
95
95
|
subject.save
|
96
|
-
}.
|
96
|
+
}.to raise_error(Ridley::Errors::InvalidResource)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
@@ -102,31 +102,31 @@ describe Ridley::ChefObject do
|
|
102
102
|
context "when the object is valid" do
|
103
103
|
let(:updated) do
|
104
104
|
updated = double('updated')
|
105
|
-
updated.
|
106
|
-
updated.
|
105
|
+
allow(updated).to receive(:[]).and_return(Hash.new)
|
106
|
+
allow(updated).to receive(:_attributes_).and_return(Hash.new)
|
107
107
|
updated
|
108
108
|
end
|
109
109
|
|
110
|
-
before(:each) { subject.
|
110
|
+
before(:each) { allow(subject).to receive(:valid?).and_return(true) }
|
111
111
|
|
112
112
|
it "sends an update message to the implementing class" do
|
113
|
-
resource.
|
113
|
+
expect(resource).to receive(:update).with(subject).and_return(updated)
|
114
114
|
subject.update
|
115
115
|
end
|
116
116
|
|
117
117
|
it "returns true" do
|
118
|
-
resource.
|
119
|
-
subject.update.
|
118
|
+
expect(resource).to receive(:update).with(subject).and_return(updated)
|
119
|
+
expect(subject.update).to eql(true)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
123
|
context "when the object is invalid" do
|
124
|
-
before(:each) { subject.
|
124
|
+
before(:each) { allow(subject).to receive(:valid?).and_return(false) }
|
125
125
|
|
126
126
|
it "raises an InvalidResource error" do
|
127
|
-
|
127
|
+
expect {
|
128
128
|
subject.update
|
129
|
-
}.
|
129
|
+
}.to raise_error(Ridley::Errors::InvalidResource)
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
@@ -134,10 +134,10 @@ describe Ridley::ChefObject do
|
|
134
134
|
describe "#chef_id" do
|
135
135
|
it "returns the value of the chef_id attribute" do
|
136
136
|
subject.class.attribute(:name)
|
137
|
-
subject.class.
|
137
|
+
allow(subject.class).to receive(:chef_id) { :name }
|
138
138
|
subject.mass_assign(name: "reset")
|
139
139
|
|
140
|
-
subject.chef_id.
|
140
|
+
expect(subject.chef_id).to eql("reset")
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -147,17 +147,17 @@ describe Ridley::ChefObject do
|
|
147
147
|
before(:each) do
|
148
148
|
subject.class.attribute(:one)
|
149
149
|
subject.class.attribute(:two)
|
150
|
-
resource.
|
150
|
+
allow(resource).to receive(:find).with(subject).and_return(updated_subject)
|
151
151
|
end
|
152
152
|
|
153
153
|
it "returns itself" do
|
154
|
-
subject.reload.
|
154
|
+
expect(subject.reload).to eql(subject)
|
155
155
|
end
|
156
156
|
|
157
157
|
it "sets the attributes of self to equal those of the updated object" do
|
158
158
|
subject.reload
|
159
159
|
|
160
|
-
subject.get_attribute(:one).
|
160
|
+
expect(subject.get_attribute(:one)).to eql("val")
|
161
161
|
end
|
162
162
|
|
163
163
|
it "does not include attributes not set by the updated object" do
|
@@ -188,7 +188,7 @@ describe Ridley::ChefObject do
|
|
188
188
|
end
|
189
189
|
|
190
190
|
it "is equal" do
|
191
|
-
one.
|
191
|
+
expect(one).to be_eql(two)
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
@@ -199,7 +199,7 @@ describe Ridley::ChefObject do
|
|
199
199
|
end
|
200
200
|
|
201
201
|
it "is not equal" do
|
202
|
-
one.
|
202
|
+
expect(one).not_to be_eql(two)
|
203
203
|
end
|
204
204
|
end
|
205
205
|
end
|
@@ -227,7 +227,7 @@ describe Ridley::ChefObject do
|
|
227
227
|
end
|
228
228
|
|
229
229
|
it "returns only one unique element" do
|
230
|
-
nodes.uniq.
|
230
|
+
expect(nodes.uniq.size).to eq(1)
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
@@ -240,7 +240,7 @@ describe Ridley::ChefObject do
|
|
240
240
|
end
|
241
241
|
|
242
242
|
it "returns all of the elements" do
|
243
|
-
nodes.uniq.
|
243
|
+
expect(nodes.uniq.size).to eq(2)
|
244
244
|
end
|
245
245
|
end
|
246
246
|
end
|
@@ -7,7 +7,7 @@ describe Ridley::CookbookObject do
|
|
7
7
|
|
8
8
|
describe "#download" do
|
9
9
|
it "downloads each file" do
|
10
|
-
subject.
|
10
|
+
allow(subject).to receive(:manifest) do
|
11
11
|
{
|
12
12
|
resources: [],
|
13
13
|
providers: [],
|
@@ -37,8 +37,8 @@ describe Ridley::CookbookObject do
|
|
37
37
|
}
|
38
38
|
end
|
39
39
|
|
40
|
-
subject.
|
41
|
-
subject.
|
40
|
+
expect(subject).to receive(:download_file).with(:recipes, "recipes/default.rb", anything)
|
41
|
+
expect(subject).to receive(:download_file).with(:files, "files/default/plugins/README", anything)
|
42
42
|
|
43
43
|
subject.download
|
44
44
|
end
|
@@ -48,11 +48,11 @@ describe Ridley::CookbookObject do
|
|
48
48
|
let(:destination) { tmp_path.join('fake.file').to_s }
|
49
49
|
|
50
50
|
before(:each) do
|
51
|
-
subject.
|
51
|
+
allow(subject).to receive(:root_files) { [ { path: 'metadata.rb', url: "http://test.it/file" } ] }
|
52
52
|
end
|
53
53
|
|
54
54
|
it "downloads the file from the file's url" do
|
55
|
-
connection.
|
55
|
+
expect(connection).to receive(:stream).with("http://test.it/file", destination)
|
56
56
|
|
57
57
|
subject.download_file(:root_file, "metadata.rb", destination)
|
58
58
|
end
|
@@ -67,27 +67,27 @@ describe Ridley::CookbookObject do
|
|
67
67
|
|
68
68
|
context "when the cookbook doesn't have the specified file" do
|
69
69
|
before(:each) do
|
70
|
-
subject.
|
70
|
+
allow(subject).to receive(:root_files) { Array.new }
|
71
71
|
end
|
72
72
|
|
73
73
|
it "returns nil" do
|
74
|
-
subject.download_file(:root_file, "metadata.rb", destination).
|
74
|
+
expect(subject.download_file(:root_file, "metadata.rb", destination)).to be_nil
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
79
|
describe "#manifest" do
|
80
80
|
it "returns a Hash" do
|
81
|
-
subject.manifest.
|
81
|
+
expect(subject.manifest).to be_a(Hash)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "has a key for each item in FILE_TYPES" do
|
85
|
-
subject.manifest.keys.
|
85
|
+
expect(subject.manifest.keys).to match_array(described_class::FILE_TYPES)
|
86
86
|
end
|
87
87
|
|
88
88
|
it "contains an empty array for each key" do
|
89
|
-
subject.manifest.
|
90
|
-
subject.manifest.values.
|
89
|
+
expect(subject.manifest).to each be_a(Array)
|
90
|
+
expect(subject.manifest.values).to each be_empty
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -95,7 +95,7 @@ describe Ridley::CookbookObject do
|
|
95
95
|
it "returns the updated self" do
|
96
96
|
other = subject.dup
|
97
97
|
other.version = "1.2.3"
|
98
|
-
resource.
|
98
|
+
expect(resource).to receive(:find).with(subject, subject.version).and_return(other)
|
99
99
|
|
100
100
|
expect(subject.reload).to eq(other)
|
101
101
|
end
|
@@ -21,7 +21,7 @@ describe Ridley::DataBagItemObject do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "returns a new object from attributes in the 'raw_data' field" do
|
24
|
-
subject.from_hash(response).attributes.
|
24
|
+
expect(subject.from_hash(response).attributes).to eql(response["raw_data"])
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -34,20 +34,20 @@ describe Ridley::DataBagItemObject do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it "returns a new object from the hash" do
|
37
|
-
subject.from_hash(response).attributes.
|
37
|
+
expect(subject.from_hash(response).attributes).to eql(response)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "#decrypt" do
|
43
43
|
before(:each) do
|
44
|
-
resource.
|
44
|
+
allow(resource).to receive_messages(encrypted_data_bag_secret: File.read(fixtures_path.join("encrypted_data_bag_secret").to_s))
|
45
45
|
end
|
46
46
|
|
47
47
|
it "decrypts an encrypted v0 value" do
|
48
48
|
subject.attributes[:test] = "Xk0E8lV9r4BhZzcg4wal0X4w9ZexN3azxMjZ9r1MCZc="
|
49
49
|
subject.decrypt
|
50
|
-
subject.attributes[:test][:database][:username].
|
50
|
+
expect(subject.attributes[:test][:database][:username]).to eq("test")
|
51
51
|
end
|
52
52
|
|
53
53
|
it "decrypts an encrypted v1 value" do
|
@@ -57,21 +57,21 @@ describe Ridley::DataBagItemObject do
|
|
57
57
|
subject.attributes[:password][:encrypted_data] = "zG+tTjtwOWA4vEYDoUwPYreXLZ1pFyKoWDGezEejmKs="
|
58
58
|
subject.attributes[:password][:iv] = "URVhHxv/ZrnABJBvl82qsg=="
|
59
59
|
subject.decrypt
|
60
|
-
subject.attributes[:password].
|
60
|
+
expect(subject.attributes[:password]).to eq("password123")
|
61
61
|
end
|
62
62
|
|
63
63
|
it "does not decrypt the id field" do
|
64
64
|
id = "dbi_id"
|
65
65
|
subject.attributes[:id] = id
|
66
66
|
subject.decrypt
|
67
|
-
subject.attributes[:id].
|
67
|
+
expect(subject.attributes[:id]).to eq(id)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
describe "#decrypt_value" do
|
72
72
|
context "when no encrypted_data_bag_secret has been configured" do
|
73
73
|
before do
|
74
|
-
resource.
|
74
|
+
allow(resource).to receive_messages(encrypted_data_bag_secret: nil)
|
75
75
|
end
|
76
76
|
|
77
77
|
it "raises an EncryptedDataBagSecretNotSet error" do
|
@@ -5,5 +5,8 @@ describe Ridley::DataBagObject do
|
|
5
5
|
let(:resource) { double('db-resource', item_resource: item_resource) }
|
6
6
|
subject { described_class.new(resource) }
|
7
7
|
|
8
|
-
|
8
|
+
describe '#item' do
|
9
|
+
subject { super().item }
|
10
|
+
it { is_expected.to be_a(Ridley::DataBagObject::DataBagItemProxy) }
|
11
|
+
end
|
9
12
|
end
|
@@ -7,10 +7,10 @@ describe Ridley::EnvironmentObject do
|
|
7
7
|
it "sets an override node attribute at the nested path" do
|
8
8
|
subject.set_override_attribute('deep.nested.item', true)
|
9
9
|
|
10
|
-
subject.override_attributes.
|
11
|
-
subject.override_attributes["deep"].
|
12
|
-
subject.override_attributes["deep"]["nested"].
|
13
|
-
subject.override_attributes["deep"]["nested"]["item"].
|
10
|
+
expect(subject.override_attributes).to have_key("deep")
|
11
|
+
expect(subject.override_attributes["deep"]).to have_key("nested")
|
12
|
+
expect(subject.override_attributes["deep"]["nested"]).to have_key("item")
|
13
|
+
expect(subject.override_attributes["deep"]["nested"]["item"]).to be_truthy
|
14
14
|
end
|
15
15
|
|
16
16
|
context "when the override attribute is already set" do
|
@@ -24,7 +24,7 @@ describe Ridley::EnvironmentObject do
|
|
24
24
|
}
|
25
25
|
subject.set_override_attribute('deep.nested.item', true)
|
26
26
|
|
27
|
-
subject.override_attributes["deep"]["nested"]["item"].
|
27
|
+
expect(subject.override_attributes["deep"]["nested"]["item"]).to be_truthy
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -33,10 +33,10 @@ describe Ridley::EnvironmentObject do
|
|
33
33
|
it "sets an override node attribute at the nested path" do
|
34
34
|
subject.set_default_attribute('deep.nested.item', true)
|
35
35
|
|
36
|
-
subject.default_attributes.
|
37
|
-
subject.default_attributes["deep"].
|
38
|
-
subject.default_attributes["deep"]["nested"].
|
39
|
-
subject.default_attributes["deep"]["nested"]["item"].
|
36
|
+
expect(subject.default_attributes).to have_key("deep")
|
37
|
+
expect(subject.default_attributes["deep"]).to have_key("nested")
|
38
|
+
expect(subject.default_attributes["deep"]["nested"]).to have_key("item")
|
39
|
+
expect(subject.default_attributes["deep"]["nested"]["item"]).to be_truthy
|
40
40
|
end
|
41
41
|
|
42
42
|
context "when the override attribute is already set" do
|
@@ -50,7 +50,7 @@ describe Ridley::EnvironmentObject do
|
|
50
50
|
}
|
51
51
|
subject.set_default_attribute('deep.nested.item', true)
|
52
52
|
|
53
|
-
subject.default_attributes["deep"]["nested"]["item"].
|
53
|
+
expect(subject.default_attributes["deep"]["nested"]["item"]).to be_truthy
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -58,10 +58,10 @@ describe Ridley::NodeObject do
|
|
58
58
|
it "sets a normal node attribute at the nested path" do
|
59
59
|
subject.set_chef_attribute('deep.nested.item', true)
|
60
60
|
|
61
|
-
subject.normal.
|
62
|
-
subject.normal["deep"].
|
63
|
-
subject.normal["deep"]["nested"].
|
64
|
-
subject.normal["deep"]["nested"]["item"].
|
61
|
+
expect(subject.normal).to have_key("deep")
|
62
|
+
expect(subject.normal["deep"]).to have_key("nested")
|
63
|
+
expect(subject.normal["deep"]["nested"]).to have_key("item")
|
64
|
+
expect(subject.normal["deep"]["nested"]["item"]).to be_truthy
|
65
65
|
end
|
66
66
|
|
67
67
|
context "when the normal attribute is already set" do
|
@@ -75,7 +75,7 @@ describe Ridley::NodeObject do
|
|
75
75
|
}
|
76
76
|
subject.set_chef_attribute('deep.nested.item', true)
|
77
77
|
|
78
|
-
subject.normal["deep"]["nested"]["item"].
|
78
|
+
expect(subject.normal["deep"]["nested"]["item"]).to be_truthy
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -123,13 +123,13 @@ describe Ridley::NodeObject do
|
|
123
123
|
"cloud" => Hash.new
|
124
124
|
}
|
125
125
|
|
126
|
-
subject.cloud
|
126
|
+
expect(subject.cloud?).to be_truthy
|
127
127
|
end
|
128
128
|
|
129
129
|
it "returns false if the cloud automatic attribute is not set" do
|
130
130
|
subject.automatic.delete(:cloud)
|
131
131
|
|
132
|
-
subject.cloud
|
132
|
+
expect(subject.cloud?).to be_falsey
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
@@ -141,13 +141,13 @@ describe Ridley::NodeObject do
|
|
141
141
|
}
|
142
142
|
}
|
143
143
|
|
144
|
-
subject.eucalyptus
|
144
|
+
expect(subject.eucalyptus?).to be_truthy
|
145
145
|
end
|
146
146
|
|
147
147
|
it "returns false if the node is not a cloud node" do
|
148
148
|
subject.automatic.delete(:cloud)
|
149
149
|
|
150
|
-
subject.eucalyptus
|
150
|
+
expect(subject.eucalyptus?).to be_falsey
|
151
151
|
end
|
152
152
|
|
153
153
|
it "returns false if the node is a cloud node but not using the eucalyptus provider" do
|
@@ -157,7 +157,7 @@ describe Ridley::NodeObject do
|
|
157
157
|
}
|
158
158
|
}
|
159
159
|
|
160
|
-
subject.eucalyptus
|
160
|
+
expect(subject.eucalyptus?).to be_falsey
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
@@ -169,13 +169,13 @@ describe Ridley::NodeObject do
|
|
169
169
|
}
|
170
170
|
}
|
171
171
|
|
172
|
-
subject.ec2
|
172
|
+
expect(subject.ec2?).to be_truthy
|
173
173
|
end
|
174
174
|
|
175
175
|
it "returns false if the node is not a cloud node" do
|
176
176
|
subject.automatic.delete(:cloud)
|
177
177
|
|
178
|
-
subject.ec2
|
178
|
+
expect(subject.ec2?).to be_falsey
|
179
179
|
end
|
180
180
|
|
181
181
|
it "returns false if the node is a cloud node but not using the ec2 provider" do
|
@@ -185,7 +185,7 @@ describe Ridley::NodeObject do
|
|
185
185
|
}
|
186
186
|
}
|
187
187
|
|
188
|
-
subject.ec2
|
188
|
+
expect(subject.ec2?).to be_falsey
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
@@ -197,13 +197,13 @@ describe Ridley::NodeObject do
|
|
197
197
|
}
|
198
198
|
}
|
199
199
|
|
200
|
-
subject.rackspace
|
200
|
+
expect(subject.rackspace?).to be_truthy
|
201
201
|
end
|
202
202
|
|
203
203
|
it "returns false if the node is not a cloud node" do
|
204
204
|
subject.automatic.delete(:cloud)
|
205
205
|
|
206
|
-
subject.rackspace
|
206
|
+
expect(subject.rackspace?).to be_falsey
|
207
207
|
end
|
208
208
|
|
209
209
|
it "returns false if the node is a cloud node but not using the rackspace provider" do
|
@@ -213,7 +213,7 @@ describe Ridley::NodeObject do
|
|
213
213
|
}
|
214
214
|
}
|
215
215
|
|
216
|
-
subject.rackspace
|
216
|
+
expect(subject.rackspace?).to be_falsey
|
217
217
|
end
|
218
218
|
end
|
219
219
|
|
@@ -225,13 +225,13 @@ describe Ridley::NodeObject do
|
|
225
225
|
}
|
226
226
|
}
|
227
227
|
|
228
|
-
subject.cloud_provider.
|
228
|
+
expect(subject.cloud_provider).to eql("ec2")
|
229
229
|
end
|
230
230
|
|
231
231
|
it "returns nil if the node is not a cloud node" do
|
232
232
|
subject.automatic.delete(:cloud)
|
233
233
|
|
234
|
-
subject.cloud_provider.
|
234
|
+
expect(subject.cloud_provider).to be_nil
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
@@ -244,7 +244,7 @@ describe Ridley::NodeObject do
|
|
244
244
|
}
|
245
245
|
}
|
246
246
|
|
247
|
-
subject.public_ipv4.
|
247
|
+
expect(subject.public_ipv4).to eql("10.0.0.1")
|
248
248
|
end
|
249
249
|
|
250
250
|
it "returns the ipaddress if the node is not a cloud node" do
|
@@ -253,7 +253,7 @@ describe Ridley::NodeObject do
|
|
253
253
|
}
|
254
254
|
subject.automatic.delete(:cloud)
|
255
255
|
|
256
|
-
subject.public_ipv4.
|
256
|
+
expect(subject.public_ipv4).to eql("192.168.1.1")
|
257
257
|
end
|
258
258
|
end
|
259
259
|
|
@@ -265,7 +265,7 @@ describe Ridley::NodeObject do
|
|
265
265
|
}
|
266
266
|
}
|
267
267
|
|
268
|
-
subject.public_hostname.
|
268
|
+
expect(subject.public_hostname).to eql("reset.cloud.riotgames.com")
|
269
269
|
end
|
270
270
|
|
271
271
|
it "returns the FQDN if the node is not a cloud node" do
|
@@ -274,7 +274,7 @@ describe Ridley::NodeObject do
|
|
274
274
|
}
|
275
275
|
subject.automatic.delete(:cloud)
|
276
276
|
|
277
|
-
subject.public_hostname.
|
277
|
+
expect(subject.public_hostname).to eql("reset.internal.riotgames.com")
|
278
278
|
end
|
279
279
|
end
|
280
280
|
|
@@ -284,14 +284,14 @@ describe Ridley::NodeObject do
|
|
284
284
|
it "appends items to the run_list" do
|
285
285
|
subject.merge_data(run_list: ["cook::one", "cook::two"])
|
286
286
|
|
287
|
-
subject.run_list.
|
287
|
+
expect(subject.run_list).to match_array(["cook::one", "cook::two"])
|
288
288
|
end
|
289
289
|
|
290
290
|
it "ensures the run_list is unique if identical items are given" do
|
291
291
|
subject.run_list = [ "cook::one" ]
|
292
292
|
subject.merge_data(run_list: ["cook::one", "cook::two"])
|
293
293
|
|
294
|
-
subject.run_list.
|
294
|
+
expect(subject.run_list).to match_array(["cook::one", "cook::two"])
|
295
295
|
end
|
296
296
|
|
297
297
|
it "deep merges attributes into the normal attributes" do
|
@@ -310,10 +310,10 @@ describe Ridley::NodeObject do
|
|
310
310
|
}
|
311
311
|
})
|
312
312
|
|
313
|
-
subject.normal[:one][:two].
|
314
|
-
subject.normal[:one][:two][:four].
|
315
|
-
subject.normal[:one][:two].
|
316
|
-
subject.normal[:one][:two][:three].
|
313
|
+
expect(subject.normal[:one][:two]).to have_key(:four)
|
314
|
+
expect(subject.normal[:one][:two][:four]).to eql(:deep)
|
315
|
+
expect(subject.normal[:one][:two]).to have_key(:three)
|
316
|
+
expect(subject.normal[:one][:two][:three]).to eql(:deep)
|
317
317
|
end
|
318
318
|
end
|
319
319
|
end
|