chef_cap 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -1
- data/lib/chef_cap/version.rb +1 -1
- data/recipes/lib/chef_cap_helper.rb +1 -0
- data/spec/chef_cap_helper_spec.rb +52 -1
- data/spec/chef_cap_spec.rb +4 -0
- metadata +3 -3
data/Gemfile
CHANGED
data/lib/chef_cap/version.rb
CHANGED
@@ -1,6 +1,53 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe ChefCapHelper do
|
4
|
+
|
5
|
+
describe ".parse_hash" do
|
6
|
+
before do
|
7
|
+
@configuration = mock
|
8
|
+
ChefCapConfiguration.configuration = @configuration
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when given a hash with hashes" do
|
12
|
+
|
13
|
+
context "given a prefix" do
|
14
|
+
it "should call itself recursively" do
|
15
|
+
@configuration.should_receive(:set).with(:prefix_somehash_somekey, "somevalue")
|
16
|
+
ChefCapHelper.parse_hash({"somehash" => {"somekey" => "somevalue"}}, "prefix")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "given no prefix" do
|
21
|
+
it "should call itself recursively" do
|
22
|
+
@configuration.should_receive(:set).with(:somehash_somekey, "somevalue")
|
23
|
+
ChefCapHelper.parse_hash({"somehash" => {"somekey" => "somevalue"}})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when given a hash with non-hashes" do
|
29
|
+
|
30
|
+
context "given a prefix" do
|
31
|
+
it "should set the key to prefix_key on the configuration" do
|
32
|
+
@configuration.should_receive(:set).with(:prefix_somekey, "somevalue")
|
33
|
+
ChefCapHelper.parse_hash({"somekey" => "somevalue"}, "prefix")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "given no prefix" do
|
38
|
+
|
39
|
+
it "should set the key value pair on the configuration" do
|
40
|
+
@configuration.should_receive(:set).with(:somekey, "somevalue")
|
41
|
+
ChefCapHelper.parse_hash({"somekey" => "somevalue"})
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should unset null values" do
|
47
|
+
@configuration.should_not_receive(:set)
|
48
|
+
ChefCapHelper.parse_hash({"somekey" => nil})
|
49
|
+
end
|
50
|
+
end
|
4
51
|
|
5
52
|
describe ".recursive_merge" do
|
6
53
|
|
@@ -20,6 +67,8 @@ describe ChefDnaParser do
|
|
20
67
|
resulting_hash["key"].should == ["value"]
|
21
68
|
resulting_hash = ChefCapHelper.recursive_merge(original_hash, "key", {:key => :value})
|
22
69
|
resulting_hash["key"].should == {:key => :value}
|
70
|
+
resulting_hash = ChefCapHelper.recursive_merge(original_hash, "key", nil)
|
71
|
+
resulting_hash["key"].should be_nil
|
23
72
|
end
|
24
73
|
|
25
74
|
it "uniquely merges the values of two arrays" do
|
@@ -41,6 +90,8 @@ describe ChefDnaParser do
|
|
41
90
|
|
42
91
|
resulting_hash = ChefCapHelper.recursive_merge(original_hash, "key", {"one" => "nottwo"})
|
43
92
|
resulting_hash["key"].should == { "one" => "nottwo" }
|
93
|
+
resulting_hash = ChefCapHelper.recursive_merge(original_hash, "key", {"one" => nil})
|
94
|
+
resulting_hash["key"].should == { "one" => nil }
|
44
95
|
end
|
45
96
|
|
46
97
|
it "merge will overwrite hashes with arrays" do
|
data/spec/chef_cap_spec.rb
CHANGED
@@ -528,12 +528,14 @@ describe "chef_cap" do
|
|
528
528
|
"four": "shouldbeoverwritten",
|
529
529
|
"five": "stringtype"
|
530
530
|
},
|
531
|
+
"somevalue": "shouldbeoverwrittenwithnull",
|
531
532
|
"run_list": ["shared"]
|
532
533
|
},
|
533
534
|
"roles": {
|
534
535
|
"role1": {
|
535
536
|
"string": "overwritten",
|
536
537
|
"simple": ["merged"],
|
538
|
+
"somevalue": null,
|
537
539
|
"run_list": ["role1", "roleshared"]
|
538
540
|
},
|
539
541
|
"role2": {
|
@@ -569,11 +571,13 @@ describe "chef_cap" do
|
|
569
571
|
server_session.things_that_were_set["node_hash_for_localhost"]["simple"].should == ["one", "two", "merged"]
|
570
572
|
server_session.things_that_were_set["node_hash_for_localhost"]["complicated"].should == {"three"=>{"alsoshared"=>["merged"], "shared"=>"overwritten"}, "four"=>"overwritten", "five"=>["newtype"]}
|
571
573
|
server_session.things_that_were_set["node_hash_for_localhost"]["string"].should == "overwritten"
|
574
|
+
server_session.things_that_were_set["node_hash_for_localhost"]["somevalue"].should be_nil
|
572
575
|
server_session.things_that_were_set["node_hash_for_localhost"]["run_list"].should == ["everything", "shared", "role1", "roleshared", "role2"]
|
573
576
|
elsif server_session.things_that_were_set.keys.include? "node_hash_for_otherhost"
|
574
577
|
server_session.things_that_were_set["node_hash_for_otherhost"]["simple"].should == ["one", "two"]
|
575
578
|
server_session.things_that_were_set["node_hash_for_otherhost"]["complicated"].should == {"three"=>{"alsoshared"=>["merged"], "shared"=>"overwritten"}, "four"=>"overwritten", "five"=>["newtype"]}
|
576
579
|
server_session.things_that_were_set["node_hash_for_otherhost"]["string"].should == "shouldbeoverwritten"
|
580
|
+
server_session.things_that_were_set["node_hash_for_otherhost"]["somevalue"].should == "shouldbeoverwrittenwithnull"
|
577
581
|
server_session.things_that_were_set["node_hash_for_otherhost"]["run_list"].should == ["everything", "shared", "role2", "roleshared"]
|
578
582
|
end
|
579
583
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Case Commons, LLC
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-03-01 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|