summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/index.html49
-rw-r--r--coverage/lib-chef-config_rb.html2
-rw-r--r--coverage/lib-chef-cookbook_rb.html718
-rw-r--r--coverage/lib-chef-mixin-check_helper_rb.html2
-rw-r--r--coverage/lib-chef-mixin-from_file_rb.html2
-rw-r--r--coverage/lib-chef-node_rb.html4
-rw-r--r--coverage/lib-chef-recipe_rb.html10
-rw-r--r--coverage/lib-chef-resource-file_rb.html2
-rw-r--r--coverage/lib-chef-resource_collection_rb.html2
-rw-r--r--coverage/lib-chef-resource_definition_rb.html2
-rw-r--r--coverage/lib-chef-resource_rb.html2
-rw-r--r--coverage/lib-chef_rb.html2
-rw-r--r--lib/chef/cookbook.rb108
-rw-r--r--lib/chef/node.rb2
-rw-r--r--lib/chef/recipe.rb8
-rw-r--r--spec/data/cookbooks/openldap/attributes/default.rb9
-rw-r--r--spec/data/cookbooks/openldap/attributes/smokey.rb1
-rw-r--r--spec/data/cookbooks/openldap/definitions/client.rb5
-rw-r--r--spec/data/cookbooks/openldap/definitions/server.rb5
-rw-r--r--spec/data/cookbooks/openldap/ignore0
-rw-r--r--spec/data/cookbooks/openldap/recipes/gigantor.rb3
-rw-r--r--spec/unit/cookbook_collection_spec.rb65
-rw-r--r--spec/unit/cookbook_spec.rb135
23 files changed, 1104 insertions, 34 deletions
diff --git a/coverage/index.html b/coverage/index.html
index d0457dcdc0..0f8159c58e 100644
--- a/coverage/index.html
+++ b/coverage/index.html
@@ -148,7 +148,7 @@ table.report tr.dark {
</script>
</head>
<body><h3>C0 code coverage information</h3>
- <p>Generated on Mon Mar 10 14:15:46 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
+ <p>Generated on Wed Mar 12 09:52:36 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
</p>
<hr/>
<table class='report'><thead><tr><td class='heading'>Name</td>
@@ -159,9 +159,9 @@ table.report tr.dark {
</tr>
</thead>
<tbody><tr class='light'><td>TOTAL</td>
- <td class='lines_total'><tt>801</tt>
+ <td class='lines_total'><tt>909</tt>
</td>
- <td class='lines_code'><tt>518</tt>
+ <td class='lines_code'><tt>597</tt>
</td>
<td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>100.0%</tt>
&nbsp;</td>
@@ -238,7 +238,34 @@ table.report tr.dark {
</table>
</td>
</tr>
- <tr class='dark'><td><a href='lib-chef-mixin-check_helper_rb.html'>lib/chef/mixin/check_helper.rb</a>
+ <tr class='dark'><td><a href='lib-chef-cookbook_rb.html'>lib/chef/cookbook.rb</a>
+ </td>
+ <td class='lines_total'><tt>108</tt>
+ </td>
+ <td class='lines_code'><tt>79</tt>
+ </td>
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>100.0%</tt>
+ &nbsp;</td>
+ <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='100'/>
+ <td class='uncovered' width='0'/>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>100.0%</tt>
+ &nbsp;</td>
+ <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='100'/>
+ <td class='uncovered' width='0'/>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr class='light'><td><a href='lib-chef-mixin-check_helper_rb.html'>lib/chef/mixin/check_helper.rb</a>
</td>
<td class='lines_total'><tt>33</tt>
</td>
@@ -265,7 +292,7 @@ table.report tr.dark {
</table>
</td>
</tr>
- <tr class='light'><td><a href='lib-chef-mixin-from_file_rb.html'>lib/chef/mixin/from_file.rb</a>
+ <tr class='dark'><td><a href='lib-chef-mixin-from_file_rb.html'>lib/chef/mixin/from_file.rb</a>
</td>
<td class='lines_total'><tt>32</tt>
</td>
@@ -292,7 +319,7 @@ table.report tr.dark {
</table>
</td>
</tr>
- <tr class='dark'><td><a href='lib-chef-node_rb.html'>lib/chef/node.rb</a>
+ <tr class='light'><td><a href='lib-chef-node_rb.html'>lib/chef/node.rb</a>
</td>
<td class='lines_total'><tt>91</tt>
</td>
@@ -319,7 +346,7 @@ table.report tr.dark {
</table>
</td>
</tr>
- <tr class='light'><td><a href='lib-chef-recipe_rb.html'>lib/chef/recipe.rb</a>
+ <tr class='dark'><td><a href='lib-chef-recipe_rb.html'>lib/chef/recipe.rb</a>
</td>
<td class='lines_total'><tt>96</tt>
</td>
@@ -346,7 +373,7 @@ table.report tr.dark {
</table>
</td>
</tr>
- <tr class='dark'><td><a href='lib-chef-resource_rb.html'>lib/chef/resource.rb</a>
+ <tr class='light'><td><a href='lib-chef-resource_rb.html'>lib/chef/resource.rb</a>
</td>
<td class='lines_total'><tt>123</tt>
</td>
@@ -373,7 +400,7 @@ table.report tr.dark {
</table>
</td>
</tr>
- <tr class='light'><td><a href='lib-chef-resource-file_rb.html'>lib/chef/resource/file.rb</a>
+ <tr class='dark'><td><a href='lib-chef-resource-file_rb.html'>lib/chef/resource/file.rb</a>
</td>
<td class='lines_total'><tt>113</tt>
</td>
@@ -400,7 +427,7 @@ table.report tr.dark {
</table>
</td>
</tr>
- <tr class='dark'><td><a href='lib-chef-resource_collection_rb.html'>lib/chef/resource_collection.rb</a>
+ <tr class='light'><td><a href='lib-chef-resource_collection_rb.html'>lib/chef/resource_collection.rb</a>
</td>
<td class='lines_total'><tt>155</tt>
</td>
@@ -427,7 +454,7 @@ table.report tr.dark {
</table>
</td>
</tr>
- <tr class='light'><td><a href='lib-chef-resource_definition_rb.html'>lib/chef/resource_definition.rb</a>
+ <tr class='dark'><td><a href='lib-chef-resource_definition_rb.html'>lib/chef/resource_definition.rb</a>
</td>
<td class='lines_total'><tt>63</tt>
</td>
diff --git a/coverage/lib-chef-config_rb.html b/coverage/lib-chef-config_rb.html
index cb231984fd..82eeadd743 100644
--- a/coverage/lib-chef-config_rb.html
+++ b/coverage/lib-chef-config_rb.html
@@ -553,7 +553,7 @@ span.run100 {
</style>
</head>
<body><h3>C0 code coverage information</h3>
- <p>Generated on Mon Mar 10 14:15:47 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
+ <p>Generated on Wed Mar 12 09:52:36 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
</p>
<hr/>
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
diff --git a/coverage/lib-chef-cookbook_rb.html b/coverage/lib-chef-cookbook_rb.html
new file mode 100644
index 0000000000..13c28d7870
--- /dev/null
+++ b/coverage/lib-chef-cookbook_rb.html
@@ -0,0 +1,718 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'><head><title>lib/chef/cookbook.rb - C0 code coverage information</title>
+ <style type='text/css'>body { background-color: rgb(240, 240, 245); }</style>
+ <style type='text/css'>span.cross-ref-title {
+ font-size: 140%;
+}
+span.cross-ref a {
+ text-decoration: none;
+}
+span.cross-ref {
+ background-color:#f3f7fa;
+ border: 1px dashed #333;
+ margin: 1em;
+ padding: 0.5em;
+ overflow: hidden;
+}
+a.crossref-toggle {
+ text-decoration: none;
+}
+span.marked0 {
+ background-color: rgb(185, 210, 200);
+ display: block;
+}
+span.marked1 {
+ background-color: rgb(190, 215, 205);
+ display: block;
+}
+span.inferred0 {
+ background-color: rgb(175, 200, 200);
+ display: block;
+}
+span.inferred1 {
+ background-color: rgb(180, 205, 205);
+ display: block;
+}
+span.uncovered0 {
+ background-color: rgb(225, 110, 110);
+ display: block;
+}
+span.uncovered1 {
+ background-color: rgb(235, 120, 120);
+ display: block;
+}
+span.overview {
+ border-bottom: 8px solid black;
+}
+div.overview {
+ border-bottom: 8px solid black;
+}
+body {
+ font-family: verdana, arial, helvetica;
+}
+div.footer {
+ font-size: 68%;
+ margin-top: 1.5em;
+}
+h1, h2, h3, h4, h5, h6 {
+ margin-bottom: 0.5em;
+}
+h5 {
+ margin-top: 0.5em;
+}
+.hidden {
+ display: none;
+}
+div.separator {
+ height: 10px;
+}
+/* Commented out for better readability, esp. on IE */
+/*
+table tr td, table tr th {
+ font-size: 68%;
+}
+td.value table tr td {
+ font-size: 11px;
+}
+*/
+table.percent_graph {
+ height: 12px;
+ border: #808080 1px solid;
+ empty-cells: show;
+}
+table.percent_graph td.covered {
+ height: 10px;
+ background: #00f000;
+}
+table.percent_graph td.uncovered {
+ height: 10px;
+ background: #e00000;
+}
+table.percent_graph td.NA {
+ height: 10px;
+ background: #eaeaea;
+}
+table.report {
+ border-collapse: collapse;
+ width: 100%;
+}
+table.report td.heading {
+ background: #dcecff;
+ border: #d0d0d0 1px solid;
+ font-weight: bold;
+ text-align: center;
+}
+table.report td.heading:hover {
+ background: #c0ffc0;
+}
+table.report td.text {
+ border: #d0d0d0 1px solid;
+}
+table.report td.value,
+table.report td.lines_total,
+table.report td.lines_code {
+ text-align: right;
+ border: #d0d0d0 1px solid;
+}
+table.report tr.light {
+ background-color: rgb(240, 240, 245);
+}
+table.report tr.dark {
+ background-color: rgb(230, 230, 235);
+}
+</style>
+ <script type='text/javascript'>
+// <![CDATA[
+ function toggleCode( id ) {
+ if ( document.getElementById )
+ elem = document.getElementById( id );
+ else if ( document.all )
+ elem = eval( "document.all." + id );
+ else
+ return false;
+
+ elemStyle = elem.style;
+
+ if ( elemStyle.display != "block" ) {
+ elemStyle.display = "block"
+ } else {
+ elemStyle.display = "none"
+ }
+
+ return true;
+ }
+
+ // Make cross-references hidden by default
+ document.writeln( "<style type=\"text/css\">span.cross-ref { display: none }</style>" )
+ // ]]>
+</script>
+ <style type='text/css'>span.run0 {
+ background-color: rgb(178, 204, 255);
+ display: block;
+}
+span.run1 {
+ background-color: rgb(178, 206, 255);
+ display: block;
+}
+span.run2 {
+ background-color: rgb(178, 209, 255);
+ display: block;
+}
+span.run3 {
+ background-color: rgb(178, 211, 255);
+ display: block;
+}
+span.run4 {
+ background-color: rgb(178, 214, 255);
+ display: block;
+}
+span.run5 {
+ background-color: rgb(178, 218, 255);
+ display: block;
+}
+span.run6 {
+ background-color: rgb(178, 220, 255);
+ display: block;
+}
+span.run7 {
+ background-color: rgb(178, 223, 255);
+ display: block;
+}
+span.run8 {
+ background-color: rgb(178, 225, 255);
+ display: block;
+}
+span.run9 {
+ background-color: rgb(178, 228, 255);
+ display: block;
+}
+span.run10 {
+ background-color: rgb(178, 232, 255);
+ display: block;
+}
+span.run11 {
+ background-color: rgb(178, 234, 255);
+ display: block;
+}
+span.run12 {
+ background-color: rgb(178, 237, 255);
+ display: block;
+}
+span.run13 {
+ background-color: rgb(178, 239, 255);
+ display: block;
+}
+span.run14 {
+ background-color: rgb(178, 242, 255);
+ display: block;
+}
+span.run15 {
+ background-color: rgb(178, 246, 255);
+ display: block;
+}
+span.run16 {
+ background-color: rgb(178, 248, 255);
+ display: block;
+}
+span.run17 {
+ background-color: rgb(178, 251, 255);
+ display: block;
+}
+span.run18 {
+ background-color: rgb(178, 253, 255);
+ display: block;
+}
+span.run19 {
+ background-color: rgb(178, 255, 253);
+ display: block;
+}
+span.run20 {
+ background-color: rgb(178, 255, 249);
+ display: block;
+}
+span.run21 {
+ background-color: rgb(178, 255, 247);
+ display: block;
+}
+span.run22 {
+ background-color: rgb(178, 255, 244);
+ display: block;
+}
+span.run23 {
+ background-color: rgb(178, 255, 242);
+ display: block;
+}
+span.run24 {
+ background-color: rgb(178, 255, 239);
+ display: block;
+}
+span.run25 {
+ background-color: rgb(178, 255, 235);
+ display: block;
+}
+span.run26 {
+ background-color: rgb(178, 255, 233);
+ display: block;
+}
+span.run27 {
+ background-color: rgb(178, 255, 230);
+ display: block;
+}
+span.run28 {
+ background-color: rgb(178, 255, 228);
+ display: block;
+}
+span.run29 {
+ background-color: rgb(178, 255, 225);
+ display: block;
+}
+span.run30 {
+ background-color: rgb(178, 255, 221);
+ display: block;
+}
+span.run31 {
+ background-color: rgb(178, 255, 219);
+ display: block;
+}
+span.run32 {
+ background-color: rgb(178, 255, 216);
+ display: block;
+}
+span.run33 {
+ background-color: rgb(178, 255, 214);
+ display: block;
+}
+span.run34 {
+ background-color: rgb(178, 255, 211);
+ display: block;
+}
+span.run35 {
+ background-color: rgb(178, 255, 207);
+ display: block;
+}
+span.run36 {
+ background-color: rgb(178, 255, 205);
+ display: block;
+}
+span.run37 {
+ background-color: rgb(178, 255, 202);
+ display: block;
+}
+span.run38 {
+ background-color: rgb(178, 255, 200);
+ display: block;
+}
+span.run39 {
+ background-color: rgb(178, 255, 197);
+ display: block;
+}
+span.run40 {
+ background-color: rgb(178, 255, 193);
+ display: block;
+}
+span.run41 {
+ background-color: rgb(178, 255, 191);
+ display: block;
+}
+span.run42 {
+ background-color: rgb(178, 255, 188);
+ display: block;
+}
+span.run43 {
+ background-color: rgb(178, 255, 186);
+ display: block;
+}
+span.run44 {
+ background-color: rgb(178, 255, 183);
+ display: block;
+}
+span.run45 {
+ background-color: rgb(178, 255, 179);
+ display: block;
+}
+span.run46 {
+ background-color: rgb(179, 255, 178);
+ display: block;
+}
+span.run47 {
+ background-color: rgb(182, 255, 178);
+ display: block;
+}
+span.run48 {
+ background-color: rgb(184, 255, 178);
+ display: block;
+}
+span.run49 {
+ background-color: rgb(187, 255, 178);
+ display: block;
+}
+span.run50 {
+ background-color: rgb(191, 255, 178);
+ display: block;
+}
+span.run51 {
+ background-color: rgb(193, 255, 178);
+ display: block;
+}
+span.run52 {
+ background-color: rgb(196, 255, 178);
+ display: block;
+}
+span.run53 {
+ background-color: rgb(198, 255, 178);
+ display: block;
+}
+span.run54 {
+ background-color: rgb(201, 255, 178);
+ display: block;
+}
+span.run55 {
+ background-color: rgb(205, 255, 178);
+ display: block;
+}
+span.run56 {
+ background-color: rgb(207, 255, 178);
+ display: block;
+}
+span.run57 {
+ background-color: rgb(210, 255, 178);
+ display: block;
+}
+span.run58 {
+ background-color: rgb(212, 255, 178);
+ display: block;
+}
+span.run59 {
+ background-color: rgb(215, 255, 178);
+ display: block;
+}
+span.run60 {
+ background-color: rgb(219, 255, 178);
+ display: block;
+}
+span.run61 {
+ background-color: rgb(221, 255, 178);
+ display: block;
+}
+span.run62 {
+ background-color: rgb(224, 255, 178);
+ display: block;
+}
+span.run63 {
+ background-color: rgb(226, 255, 178);
+ display: block;
+}
+span.run64 {
+ background-color: rgb(229, 255, 178);
+ display: block;
+}
+span.run65 {
+ background-color: rgb(233, 255, 178);
+ display: block;
+}
+span.run66 {
+ background-color: rgb(235, 255, 178);
+ display: block;
+}
+span.run67 {
+ background-color: rgb(238, 255, 178);
+ display: block;
+}
+span.run68 {
+ background-color: rgb(240, 255, 178);
+ display: block;
+}
+span.run69 {
+ background-color: rgb(243, 255, 178);
+ display: block;
+}
+span.run70 {
+ background-color: rgb(247, 255, 178);
+ display: block;
+}
+span.run71 {
+ background-color: rgb(249, 255, 178);
+ display: block;
+}
+span.run72 {
+ background-color: rgb(252, 255, 178);
+ display: block;
+}
+span.run73 {
+ background-color: rgb(255, 255, 178);
+ display: block;
+}
+span.run74 {
+ background-color: rgb(255, 252, 178);
+ display: block;
+}
+span.run75 {
+ background-color: rgb(255, 248, 178);
+ display: block;
+}
+span.run76 {
+ background-color: rgb(255, 246, 178);
+ display: block;
+}
+span.run77 {
+ background-color: rgb(255, 243, 178);
+ display: block;
+}
+span.run78 {
+ background-color: rgb(255, 240, 178);
+ display: block;
+}
+span.run79 {
+ background-color: rgb(255, 238, 178);
+ display: block;
+}
+span.run80 {
+ background-color: rgb(255, 234, 178);
+ display: block;
+}
+span.run81 {
+ background-color: rgb(255, 232, 178);
+ display: block;
+}
+span.run82 {
+ background-color: rgb(255, 229, 178);
+ display: block;
+}
+span.run83 {
+ background-color: rgb(255, 226, 178);
+ display: block;
+}
+span.run84 {
+ background-color: rgb(255, 224, 178);
+ display: block;
+}
+span.run85 {
+ background-color: rgb(255, 220, 178);
+ display: block;
+}
+span.run86 {
+ background-color: rgb(255, 218, 178);
+ display: block;
+}
+span.run87 {
+ background-color: rgb(255, 215, 178);
+ display: block;
+}
+span.run88 {
+ background-color: rgb(255, 212, 178);
+ display: block;
+}
+span.run89 {
+ background-color: rgb(255, 210, 178);
+ display: block;
+}
+span.run90 {
+ background-color: rgb(255, 206, 178);
+ display: block;
+}
+span.run91 {
+ background-color: rgb(255, 204, 178);
+ display: block;
+}
+span.run92 {
+ background-color: rgb(255, 201, 178);
+ display: block;
+}
+span.run93 {
+ background-color: rgb(255, 198, 178);
+ display: block;
+}
+span.run94 {
+ background-color: rgb(255, 196, 178);
+ display: block;
+}
+span.run95 {
+ background-color: rgb(255, 192, 178);
+ display: block;
+}
+span.run96 {
+ background-color: rgb(255, 189, 178);
+ display: block;
+}
+span.run97 {
+ background-color: rgb(255, 187, 178);
+ display: block;
+}
+span.run98 {
+ background-color: rgb(255, 184, 178);
+ display: block;
+}
+span.run99 {
+ background-color: rgb(255, 182, 178);
+ display: block;
+}
+span.run100 {
+ background-color: rgb(255, 178, 178);
+ display: block;
+}
+</style>
+ </head>
+ <body><h3>C0 code coverage information</h3>
+ <p>Generated on Wed Mar 12 09:52:36 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
+ </p>
+ <hr/>
+ <pre><span class='marked0'>Code reported as executed by Ruby looks like this...
+</span><span class='marked1'>and this: this line is also marked as covered.
+</span><span class='inferred0'>Lines considered as run by rcov, but not reported by Ruby, look like this,
+</span><span class='inferred1'>and this: these lines were inferred by rcov (using simple heuristics).
+</span><span class='uncovered0'>Finally, here&apos;s a line marked as not executed.
+</span></pre>
+<table class='report'><thead><tr><td class='heading'>Name</td>
+ <td class='heading'>Total lines</td>
+ <td class='heading'>Lines of code</td>
+ <td class='heading'>Total coverage</td>
+ <td class='heading'>Code coverage</td>
+ </tr>
+ </thead>
+ <tbody><tr class='light'><td><a href='lib-chef-cookbook_rb.html'>lib/chef/cookbook.rb</a>
+ </td>
+ <td class='lines_total'><tt>108</tt>
+ </td>
+ <td class='lines_code'><tt>79</tt>
+ </td>
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_total'>100.0%</tt>
+ &nbsp;</td>
+ <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='100'/>
+ <td class='uncovered' width='0'/>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td><table cellspacing='0' cellpadding='0' align='right'><tr><td><tt class='coverage_code'>100.0%</tt>
+ &nbsp;</td>
+ <td><table cellspacing='0' class='percent_graph' cellpadding='0' width='100'><tr><td class='covered' width='100'/>
+ <td class='uncovered' width='0'/>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+<pre><span class="inferred0"><a name="line1"></a> 1 #
+</span><span class="inferred1"><a name="line2"></a> 2 # Author:: Adam Jacob (&lt;adam@hjksolutions.com&gt;)
+</span><span class="inferred0"><a name="line3"></a> 3 # Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+</span><span class="inferred1"><a name="line4"></a> 4 # License:: GNU General Public License version 2 or later
+</span><span class="inferred0"><a name="line5"></a> 5 #
+</span><span class="inferred1"><a name="line6"></a> 6 # This program and entire repository is free software; you can
+</span><span class="inferred0"><a name="line7"></a> 7 # redistribute it and/or modify it under the terms of the GNU
+</span><span class="inferred1"><a name="line8"></a> 8 # General Public License as published by the Free Software
+</span><span class="inferred0"><a name="line9"></a> 9 # Foundation; either version 2 of the License, or any later version.
+</span><span class="inferred1"><a name="line10"></a> 10 #
+</span><span class="inferred0"><a name="line11"></a> 11 # This program is distributed in the hope that it will be useful,
+</span><span class="inferred1"><a name="line12"></a> 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
+</span><span class="inferred0"><a name="line13"></a> 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+</span><span class="inferred1"><a name="line14"></a> 14 # GNU General Public License for more details.
+</span><span class="inferred0"><a name="line15"></a> 15 #
+</span><span class="inferred1"><a name="line16"></a> 16 # You should have received a copy of the GNU General Public License
+</span><span class="inferred0"><a name="line17"></a> 17 # along with this program; if not, write to the Free Software
+</span><span class="inferred1"><a name="line18"></a> 18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+</span><span class="inferred0"><a name="line19"></a> 19 #
+</span><span class="inferred1"><a name="line20"></a> 20
+</span><span class="marked0"><a name="line21"></a> 21 class Chef
+</span><span class="marked1"><a name="line22"></a> 22 class Cookbook
+</span><span class="inferred0"><a name="line23"></a> 23
+</span><span class="marked1"><a name="line24"></a> 24 attr_accessor :attribute_files, :definition_files, :name
+</span><span class="marked0"><a name="line25"></a> 25 attr_reader :recipe_files
+</span><span class="inferred1"><a name="line26"></a> 26
+</span><span class="marked0"><a name="line27"></a> 27 def initialize(name)
+</span><span class="marked1"><a name="line28"></a> 28 @name = name
+</span><span class="marked0"><a name="line29"></a> 29 @attribute_files = Array.new
+</span><span class="marked1"><a name="line30"></a> 30 @definition_files = Array.new
+</span><span class="marked0"><a name="line31"></a> 31 @recipe_files = Array.new
+</span><span class="marked1"><a name="line32"></a> 32 @recipe_names = Hash.new
+</span><span class="inferred0"><a name="line33"></a> 33 end
+</span><span class="inferred1"><a name="line34"></a> 34
+</span><span class="marked0"><a name="line35"></a> 35 def load_attributes(node)
+</span><span class="marked1"><a name="line36"></a> 36 unless node.kind_of?(Chef::Node)
+</span><span class="marked0"><a name="line37"></a> 37 raise ArgumentError, &quot;You must pass a Chef::Node to load_attributes!&quot;
+</span><span class="inferred1"><a name="line38"></a> 38 end
+</span><span class="marked0"><a name="line39"></a> 39 @attribute_files.each do |file|
+</span><span class="marked1"><a name="line40"></a> 40 node.from_file(file)
+</span><span class="inferred0"><a name="line41"></a> 41 end
+</span><span class="marked1"><a name="line42"></a> 42 node
+</span><span class="inferred0"><a name="line43"></a> 43 end
+</span><span class="inferred1"><a name="line44"></a> 44
+</span><span class="marked0"><a name="line45"></a> 45 def load_definitions
+</span><span class="marked1"><a name="line46"></a> 46 results = Hash.new
+</span><span class="marked0"><a name="line47"></a> 47 @definition_files.each do |file|
+</span><span class="marked1"><a name="line48"></a> 48 resourcedef = Chef::ResourceDefinition.new
+</span><span class="marked0"><a name="line49"></a> 49 resourcedef.from_file(file)
+</span><span class="marked1"><a name="line50"></a> 50 results[resourcedef.name] = resourcedef
+</span><span class="inferred0"><a name="line51"></a> 51 end
+</span><span class="marked1"><a name="line52"></a> 52 results
+</span><span class="inferred0"><a name="line53"></a> 53 end
+</span><span class="inferred1"><a name="line54"></a> 54
+</span><span class="marked0"><a name="line55"></a> 55 def recipe_files=(*args)
+</span><span class="marked1"><a name="line56"></a> 56 @recipe_files = args.flatten
+</span><span class="marked0"><a name="line57"></a> 57 @recipe_files.each_index do |i|
+</span><span class="marked1"><a name="line58"></a> 58 file = @recipe_files[i]
+</span><span class="marked0"><a name="line59"></a> 59 case file
+</span><span class="marked1"><a name="line60"></a> 60 when /(.+\/)(.+).rb$/
+</span><span class="marked0"><a name="line61"></a> 61 @recipe_names[$2] = i
+</span><span class="marked1"><a name="line62"></a> 62 when /(.+).rb$/
+</span><span class="marked0"><a name="line63"></a> 63 @recipe_names[$1] = i
+</span><span class="inferred1"><a name="line64"></a> 64 else
+</span><span class="marked0"><a name="line65"></a> 65 @recipe_names[file] = i
+</span><span class="inferred1"><a name="line66"></a> 66 end
+</span><span class="inferred0"><a name="line67"></a> 67 end
+</span><span class="marked1"><a name="line68"></a> 68 @recipe_files
+</span><span class="inferred0"><a name="line69"></a> 69 end
+</span><span class="inferred1"><a name="line70"></a> 70
+</span><span class="marked0"><a name="line71"></a> 71 def recipe?(name)
+</span><span class="marked1"><a name="line72"></a> 72 lookup_name = name
+</span><span class="marked0"><a name="line73"></a> 73 if name =~ /(.+)::(.+)/
+</span><span class="marked1"><a name="line74"></a> 74 cookbook_name = $1
+</span><span class="marked0"><a name="line75"></a> 75 lookup_name = $2
+</span><span class="marked1"><a name="line76"></a> 76 return false unless cookbook_name == @name
+</span><span class="inferred0"><a name="line77"></a> 77 end
+</span><span class="marked1"><a name="line78"></a> 78 @recipe_names.has_key?(lookup_name)
+</span><span class="inferred0"><a name="line79"></a> 79 end
+</span><span class="inferred1"><a name="line80"></a> 80
+</span><span class="marked0"><a name="line81"></a> 81 def recipes
+</span><span class="marked1"><a name="line82"></a> 82 results = Array.new
+</span><span class="marked0"><a name="line83"></a> 83 @recipe_names.each_key do |rname|
+</span><span class="marked1"><a name="line84"></a> 84 results &lt;&lt; &quot;#{@name}::#{rname}&quot;
+</span><span class="inferred0"><a name="line85"></a> 85 end
+</span><span class="marked1"><a name="line86"></a> 86 results
+</span><span class="inferred0"><a name="line87"></a> 87 end
+</span><span class="inferred1"><a name="line88"></a> 88
+</span><span class="marked0"><a name="line89"></a> 89 def load_recipe(name, node, collection=nil, definitions=nil, config=nil)
+</span><span class="marked1"><a name="line90"></a> 90 cookbook_name = @name
+</span><span class="marked0"><a name="line91"></a> 91 recipe_name = nil
+</span><span class="marked1"><a name="line92"></a> 92 case name
+</span><span class="marked0"><a name="line93"></a> 93 when /^(.+)::(.+)$/
+</span><span class="marked1"><a name="line94"></a> 94 recipe_name = $2
+</span><span class="inferred0"><a name="line95"></a> 95 else
+</span><span class="marked1"><a name="line96"></a> 96 recipe_name = name
+</span><span class="inferred0"><a name="line97"></a> 97 end
+</span><span class="marked1"><a name="line98"></a> 98 unless @recipe_names.has_key?(recipe_name)
+</span><span class="marked0"><a name="line99"></a> 99 raise ArgumentError, &quot;Cannot find a recipe matching #{recipe_name} in cookbook #{@name}&quot;
+</span><span class="inferred1"><a name="line100"></a>100 end
+</span><span class="marked0"><a name="line101"></a>101 recipe = Chef::Recipe.new(cookbook_name, recipe_name, node,
+</span><span class="inferred1"><a name="line102"></a>102 collection, definitions, config)
+</span><span class="marked0"><a name="line103"></a>103 recipe.from_file(@recipe_files[@recipe_names[recipe_name]])
+</span><span class="marked1"><a name="line104"></a>104 recipe
+</span><span class="inferred0"><a name="line105"></a>105 end
+</span><span class="inferred1"><a name="line106"></a>106
+</span><span class="inferred0"><a name="line107"></a>107 end
+</span><span class="inferred1"><a name="line108"></a>108 end
+</span></pre><hr/>
+ <p>Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'>rcov code coverage analysis tool for Ruby</a>
+ version 0.8.1.2.</p>
+<p><a href='http://validator.w3.org/check/referer'><img src='http://www.w3.org/Icons/valid-xhtml10' height='31' alt='Valid XHTML 1.0!' width='88'/>
+ </a>
+ <a href='http://jigsaw.w3.org/css-validator/check/referer'><img src='http://jigsaw.w3.org/css-validator/images/vcss' alt='Valid CSS!' style='border:0;width:88px;height:31px'/>
+ </a>
+ </p>
+ </body>
+ </html>
diff --git a/coverage/lib-chef-mixin-check_helper_rb.html b/coverage/lib-chef-mixin-check_helper_rb.html
index 8835f7b59c..5ec5e3d54b 100644
--- a/coverage/lib-chef-mixin-check_helper_rb.html
+++ b/coverage/lib-chef-mixin-check_helper_rb.html
@@ -553,7 +553,7 @@ span.run100 {
</style>
</head>
<body><h3>C0 code coverage information</h3>
- <p>Generated on Mon Mar 10 14:15:47 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
+ <p>Generated on Wed Mar 12 09:52:36 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
</p>
<hr/>
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
diff --git a/coverage/lib-chef-mixin-from_file_rb.html b/coverage/lib-chef-mixin-from_file_rb.html
index 1a3719980b..ceb17aa4d5 100644
--- a/coverage/lib-chef-mixin-from_file_rb.html
+++ b/coverage/lib-chef-mixin-from_file_rb.html
@@ -553,7 +553,7 @@ span.run100 {
</style>
</head>
<body><h3>C0 code coverage information</h3>
- <p>Generated on Mon Mar 10 14:15:47 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
+ <p>Generated on Wed Mar 12 09:52:36 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
</p>
<hr/>
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
diff --git a/coverage/lib-chef-node_rb.html b/coverage/lib-chef-node_rb.html
index 86a03e5892..565e54a41b 100644
--- a/coverage/lib-chef-node_rb.html
+++ b/coverage/lib-chef-node_rb.html
@@ -553,7 +553,7 @@ span.run100 {
</style>
</head>
<body><h3>C0 code coverage information</h3>
- <p>Generated on Mon Mar 10 14:15:47 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
+ <p>Generated on Wed Mar 12 09:52:36 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
</p>
<hr/>
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
@@ -679,7 +679,7 @@ span.run100 {
</span><span class="marked1"><a name="line79"></a>79 if args.length != 0
</span><span class="marked0"><a name="line80"></a>80 @attribute[symbol] = args.length == 1 ? args[0] : args
</span><span class="inferred1"><a name="line81"></a>81 else
-</span><span class="marked0"><a name="line82"></a>82 if self[symbol]
+</span><span class="marked0"><a name="line82"></a>82 if @attribute.has_key?(symbol)
</span><span class="marked1"><a name="line83"></a>83 @attribute[symbol]
</span><span class="inferred0"><a name="line84"></a>84 else
</span><span class="marked1"><a name="line85"></a>85 raise ArgumentError, &quot;Attribute #{symbol.to_s} is not defined!&quot;
diff --git a/coverage/lib-chef-recipe_rb.html b/coverage/lib-chef-recipe_rb.html
index ee8434f7b7..e58968b88b 100644
--- a/coverage/lib-chef-recipe_rb.html
+++ b/coverage/lib-chef-recipe_rb.html
@@ -553,7 +553,7 @@ span.run100 {
</style>
</head>
<body><h3>C0 code coverage information</h3>
- <p>Generated on Mon Mar 10 14:15:48 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
+ <p>Generated on Wed Mar 12 09:52:36 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
</p>
<hr/>
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
@@ -625,11 +625,11 @@ span.run100 {
</span><span class="inferred0"><a name="line25"></a>25
</span><span class="marked1"><a name="line26"></a>26 include Chef::Mixin::FromFile
</span><span class="inferred0"><a name="line27"></a>27
-</span><span class="marked1"><a name="line28"></a>28 attr_accessor :module_name, :recipe_name, :recipe, :node, :collection,
+</span><span class="marked1"><a name="line28"></a>28 attr_accessor :cookbook_name, :recipe_name, :recipe, :node, :collection,
</span><span class="inferred0"><a name="line29"></a>29 :definitions, :config, :params
</span><span class="inferred1"><a name="line30"></a>30
-</span><span class="marked0"><a name="line31"></a>31 def initialize(module_name, recipe_name, node, collection=nil, definitions=nil, config=nil)
-</span><span class="marked1"><a name="line32"></a>32 @module_name = module_name
+</span><span class="marked0"><a name="line31"></a>31 def initialize(cookbook_name, recipe_name, node, collection=nil, definitions=nil, config=nil)
+</span><span class="marked1"><a name="line32"></a>32 @cookbook_name = cookbook_name
</span><span class="marked0"><a name="line33"></a>33 @recipe_name = recipe_name
</span><span class="marked1"><a name="line34"></a>34 @node = node
</span><span class="marked0"><a name="line35"></a>35 if collection
@@ -662,7 +662,7 @@ span.run100 {
</span><span class="marked1"><a name="line62"></a>62 if @definitions.has_key?(method_symbol)
</span><span class="marked0"><a name="line63"></a>63 new_def = @definitions[method_symbol].dup
</span><span class="marked1"><a name="line64"></a>64 new_def.instance_eval(&amp;block)
-</span><span class="marked0"><a name="line65"></a>65 new_recipe = Chef::Recipe.new(@module_name, @recipe_name, @node, @collection, @definitions, @config)
+</span><span class="marked0"><a name="line65"></a>65 new_recipe = Chef::Recipe.new(@cookbook_name, @recipe_name, @node, @collection, @definitions, @config)
</span><span class="marked1"><a name="line66"></a>66 new_recipe.params = new_def.params
</span><span class="marked0"><a name="line67"></a>67 new_recipe.instance_eval(&amp;new_def.recipe)
</span><span class="inferred1"><a name="line68"></a>68 else
diff --git a/coverage/lib-chef-resource-file_rb.html b/coverage/lib-chef-resource-file_rb.html
index 6bc7111f4a..2a792cafbb 100644
--- a/coverage/lib-chef-resource-file_rb.html
+++ b/coverage/lib-chef-resource-file_rb.html
@@ -553,7 +553,7 @@ span.run100 {
</style>
</head>
<body><h3>C0 code coverage information</h3>
- <p>Generated on Mon Mar 10 14:15:48 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
+ <p>Generated on Wed Mar 12 09:52:37 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
</p>
<hr/>
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
diff --git a/coverage/lib-chef-resource_collection_rb.html b/coverage/lib-chef-resource_collection_rb.html
index 1938f5ef29..b32bc57709 100644
--- a/coverage/lib-chef-resource_collection_rb.html
+++ b/coverage/lib-chef-resource_collection_rb.html
@@ -553,7 +553,7 @@ span.run100 {
</style>
</head>
<body><h3>C0 code coverage information</h3>
- <p>Generated on Mon Mar 10 14:15:49 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
+ <p>Generated on Wed Mar 12 09:52:37 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
</p>
<hr/>
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
diff --git a/coverage/lib-chef-resource_definition_rb.html b/coverage/lib-chef-resource_definition_rb.html
index 7dc9116e77..a502ffb3cd 100644
--- a/coverage/lib-chef-resource_definition_rb.html
+++ b/coverage/lib-chef-resource_definition_rb.html
@@ -553,7 +553,7 @@ span.run100 {
</style>
</head>
<body><h3>C0 code coverage information</h3>
- <p>Generated on Mon Mar 10 14:15:50 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
+ <p>Generated on Wed Mar 12 09:52:37 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
</p>
<hr/>
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
diff --git a/coverage/lib-chef-resource_rb.html b/coverage/lib-chef-resource_rb.html
index 77d7d728ed..1657a2743c 100644
--- a/coverage/lib-chef-resource_rb.html
+++ b/coverage/lib-chef-resource_rb.html
@@ -553,7 +553,7 @@ span.run100 {
</style>
</head>
<body><h3>C0 code coverage information</h3>
- <p>Generated on Mon Mar 10 14:15:48 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
+ <p>Generated on Wed Mar 12 09:52:36 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
</p>
<hr/>
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
diff --git a/coverage/lib-chef_rb.html b/coverage/lib-chef_rb.html
index 1a46f97fef..698627fa66 100644
--- a/coverage/lib-chef_rb.html
+++ b/coverage/lib-chef_rb.html
@@ -553,7 +553,7 @@ span.run100 {
</style>
</head>
<body><h3>C0 code coverage information</h3>
- <p>Generated on Mon Mar 10 14:15:47 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
+ <p>Generated on Wed Mar 12 09:52:36 -0700 2008 with <a href='http://eigenclass.org/hiki/rcov'>rcov 0.8.1.2</a>
</p>
<hr/>
<pre><span class='marked0'>Code reported as executed by Ruby looks like this...
diff --git a/lib/chef/cookbook.rb b/lib/chef/cookbook.rb
new file mode 100644
index 0000000000..c69491c2f2
--- /dev/null
+++ b/lib/chef/cookbook.rb
@@ -0,0 +1,108 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: GNU General Public License version 2 or later
+#
+# This program and entire repository is free software; you can
+# redistribute it and/or modify it under the terms of the GNU
+# General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+class Chef
+ class Cookbook
+
+ attr_accessor :attribute_files, :definition_files, :name
+ attr_reader :recipe_files
+
+ def initialize(name)
+ @name = name
+ @attribute_files = Array.new
+ @definition_files = Array.new
+ @recipe_files = Array.new
+ @recipe_names = Hash.new
+ end
+
+ def load_attributes(node)
+ unless node.kind_of?(Chef::Node)
+ raise ArgumentError, "You must pass a Chef::Node to load_attributes!"
+ end
+ @attribute_files.each do |file|
+ node.from_file(file)
+ end
+ node
+ end
+
+ def load_definitions
+ results = Hash.new
+ @definition_files.each do |file|
+ resourcedef = Chef::ResourceDefinition.new
+ resourcedef.from_file(file)
+ results[resourcedef.name] = resourcedef
+ end
+ results
+ end
+
+ def recipe_files=(*args)
+ @recipe_files = args.flatten
+ @recipe_files.each_index do |i|
+ file = @recipe_files[i]
+ case file
+ when /(.+\/)(.+).rb$/
+ @recipe_names[$2] = i
+ when /(.+).rb$/
+ @recipe_names[$1] = i
+ else
+ @recipe_names[file] = i
+ end
+ end
+ @recipe_files
+ end
+
+ def recipe?(name)
+ lookup_name = name
+ if name =~ /(.+)::(.+)/
+ cookbook_name = $1
+ lookup_name = $2
+ return false unless cookbook_name == @name
+ end
+ @recipe_names.has_key?(lookup_name)
+ end
+
+ def recipes
+ results = Array.new
+ @recipe_names.each_key do |rname|
+ results << "#{@name}::#{rname}"
+ end
+ results
+ end
+
+ def load_recipe(name, node, collection=nil, definitions=nil, config=nil)
+ cookbook_name = @name
+ recipe_name = nil
+ case name
+ when /^(.+)::(.+)$/
+ recipe_name = $2
+ else
+ recipe_name = name
+ end
+ unless @recipe_names.has_key?(recipe_name)
+ raise ArgumentError, "Cannot find a recipe matching #{recipe_name} in cookbook #{@name}"
+ end
+ recipe = Chef::Recipe.new(cookbook_name, recipe_name, node,
+ collection, definitions, config)
+ recipe.from_file(@recipe_files[@recipe_names[recipe_name]])
+ recipe
+ end
+
+ end
+end \ No newline at end of file
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index bcda384d09..69dc6ab3f0 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -79,7 +79,7 @@ class Chef
if args.length != 0
@attribute[symbol] = args.length == 1 ? args[0] : args
else
- if self[symbol]
+ if @attribute.has_key?(symbol)
@attribute[symbol]
else
raise ArgumentError, "Attribute #{symbol.to_s} is not defined!"
diff --git a/lib/chef/recipe.rb b/lib/chef/recipe.rb
index 17d14ef0bf..81fb979de2 100644
--- a/lib/chef/recipe.rb
+++ b/lib/chef/recipe.rb
@@ -25,11 +25,11 @@ class Chef
include Chef::Mixin::FromFile
- attr_accessor :module_name, :recipe_name, :recipe, :node, :collection,
+ attr_accessor :cookbook_name, :recipe_name, :recipe, :node, :collection,
:definitions, :config, :params
- def initialize(module_name, recipe_name, node, collection=nil, definitions=nil, config=nil)
- @module_name = module_name
+ def initialize(cookbook_name, recipe_name, node, collection=nil, definitions=nil, config=nil)
+ @cookbook_name = cookbook_name
@recipe_name = recipe_name
@node = node
if collection
@@ -62,7 +62,7 @@ class Chef
if @definitions.has_key?(method_symbol)
new_def = @definitions[method_symbol].dup
new_def.instance_eval(&block)
- new_recipe = Chef::Recipe.new(@module_name, @recipe_name, @node, @collection, @definitions, @config)
+ new_recipe = Chef::Recipe.new(@cookbook_name, @recipe_name, @node, @collection, @definitions, @config)
new_recipe.params = new_def.params
new_recipe.instance_eval(&new_def.recipe)
else
diff --git a/spec/data/cookbooks/openldap/attributes/default.rb b/spec/data/cookbooks/openldap/attributes/default.rb
index d5ef90f6c4..652fc18a20 100644
--- a/spec/data/cookbooks/openldap/attributes/default.rb
+++ b/spec/data/cookbooks/openldap/attributes/default.rb
@@ -1,11 +1,14 @@
-
case chef_env
when "prod"
ldap_server "ops1prod"
ldap_basedn "dc=hjksolutions,dc=com"
- ldap_replication_password "RiotAct"
+ ldap_replication_password "yes"
when "corp"
ldap_server "ops1prod"
ldap_basedn "dc=hjksolutions,dc=com"
- ldap_replication_password "KickingMeDown"
+ ldap_replication_password "yougotit"
+else
+ ldap_server "ops1prod"
+ ldap_basedn "dc=hjksolutions,dc=com"
+ ldap_replication_password "forsure"
end
diff --git a/spec/data/cookbooks/openldap/attributes/smokey.rb b/spec/data/cookbooks/openldap/attributes/smokey.rb
new file mode 100644
index 0000000000..63f5b56c7f
--- /dev/null
+++ b/spec/data/cookbooks/openldap/attributes/smokey.rb
@@ -0,0 +1 @@
+smokey "robinson" \ No newline at end of file
diff --git a/spec/data/cookbooks/openldap/definitions/client.rb b/spec/data/cookbooks/openldap/definitions/client.rb
new file mode 100644
index 0000000000..37364925fb
--- /dev/null
+++ b/spec/data/cookbooks/openldap/definitions/client.rb
@@ -0,0 +1,5 @@
+define :openldap_client, :mothra => "a big monster" do
+ cat "#{param[:name]}" do
+ pretty_kitty true
+ end
+end
diff --git a/spec/data/cookbooks/openldap/definitions/server.rb b/spec/data/cookbooks/openldap/definitions/server.rb
new file mode 100644
index 0000000000..f189f67ca8
--- /dev/null
+++ b/spec/data/cookbooks/openldap/definitions/server.rb
@@ -0,0 +1,5 @@
+define :openldap_server, :mothra => "a big monster" do
+ cat "#{param[:name]}" do
+ pretty_kitty true
+ end
+end
diff --git a/spec/data/cookbooks/openldap/ignore b/spec/data/cookbooks/openldap/ignore
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/spec/data/cookbooks/openldap/ignore
diff --git a/spec/data/cookbooks/openldap/recipes/gigantor.rb b/spec/data/cookbooks/openldap/recipes/gigantor.rb
new file mode 100644
index 0000000000..4ebbaeb22d
--- /dev/null
+++ b/spec/data/cookbooks/openldap/recipes/gigantor.rb
@@ -0,0 +1,3 @@
+cat "blanket" do
+ pretty_kitty false
+end \ No newline at end of file
diff --git a/spec/unit/cookbook_collection_spec.rb b/spec/unit/cookbook_collection_spec.rb
new file mode 100644
index 0000000000..c2b7b976f9
--- /dev/null
+++ b/spec/unit/cookbook_collection_spec.rb
@@ -0,0 +1,65 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: GNU General Public License version 2 or later
+#
+# This program and entire repository is free software; you can
+# redistribute it and/or modify it under the terms of the GNU
+# General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+# require File.join(File.dirname(__FILE__), "..", "spec_helper")
+#
+# describe Chef::CookbookCollection do
+# before(:each) do
+# config = Chef::Config.new
+# config.cookbook_path = [
+# File.join(File.dirname(__FILE__), "..", "data", "cookbooks")
+# File.join(File.dirname(__FILE__), "..", "data", "kitchen-cookbooks")
+# ]
+# @cc = Chef::CookbookCollection.new(config)
+# end
+#
+# it "should be a Chef::CookbookCollection object" do
+# @cookbooks.should be_kind_of(Chef::CookbookCollection)
+# end
+#
+# it "should return a list of available cookbooks as []" do
+# @cookbooks[:openldap].should
+# end
+#
+# it "should allow you to iterate over cookbooks with each" do
+# end
+#
+# it "should auto-load a cookbook via [] if it isn't loaded already" do
+# end
+#
+# it "should find all the cookbooks in the cookbook path" do
+# end
+#
+# it "should allow you to override an attribute file via cookbook_path" do
+# end
+#
+# it "should allow you to override a definition file via cookbook_path" do
+# end
+#
+# it "should allow you to override a recipe file via cookbook_path" do
+# end
+#
+# it "should allow you to declare a cookbook as 'final', and not look for any other" do
+# end
+#
+# it "should allwo you to have an 'ignore' file, which skips loading files in later cookbooks" do
+# end
+#
+# end \ No newline at end of file
diff --git a/spec/unit/cookbook_spec.rb b/spec/unit/cookbook_spec.rb
new file mode 100644
index 0000000000..1e44f519f7
--- /dev/null
+++ b/spec/unit/cookbook_spec.rb
@@ -0,0 +1,135 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: GNU General Public License version 2 or later
+#
+# This program and entire repository is free software; you can
+# redistribute it and/or modify it under the terms of the GNU
+# General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+require File.join(File.dirname(__FILE__), "..", "spec_helper")
+
+describe Chef::Cookbook do
+ COOKBOOK_PATH = File.join(File.dirname(__FILE__), "..", "data", "cookbooks", "openldap")
+
+ before(:each) do
+ @cookbook = Chef::Cookbook.new("openldap")
+ end
+
+ it "should be a Chef::Cookbook object" do
+ @cookbook.should be_kind_of(Chef::Cookbook)
+ end
+
+ it "should have a name" do
+ @cookbook.name.should eql("openldap")
+ end
+
+ it "should have a list of attribute files" do
+ @cookbook.attribute_files.should be_kind_of(Array)
+ end
+
+ it "should allow you to set the list of attribute files" do
+ @cookbook.attribute_files = [ "one", "two" ]
+ @cookbook.attribute_files.should eql(["one", "two"])
+ end
+
+ it "should allow you to load all the attributes" do
+ node = Chef::Node.new
+ node.name "Julia Child"
+ node.chef_env false
+ @cookbook.attribute_files = Dir[File.join(COOKBOOK_PATH, "attributes", "**", "*.rb")]
+ node = @cookbook.load_attributes(node)
+ node.ldap_server.should eql("ops1prod")
+ node.ldap_basedn.should eql("dc=hjksolutions,dc=com")
+ node.ldap_replication_password.should eql("forsure")
+ node.smokey.should eql("robinson")
+ end
+
+ it "should raise an ArgumentError if you don't pass a node object to load_attributes" do
+ lambda { @cookbook.load_attributes("snake oil") }.should raise_error(ArgumentError)
+ end
+
+ it "should have a list of definition files" do
+ @cookbook.definition_files.should be_a_kind_of(Array)
+ end
+
+ it "should allow you to set the list of definition files" do
+ @cookbook.definition_files = [ "one", "two" ]
+ @cookbook.definition_files.should eql(["one", "two"])
+ end
+
+ it "should allow you to load all the definitions, returning a hash of ResourceDefinitions by name" do
+ @cookbook.definition_files = Dir[File.join(COOKBOOK_PATH, "definitions", "**", "*.rb")]
+ defs = @cookbook.load_definitions
+ defs.has_key?(:openldap_server).should eql(true)
+ defs[:openldap_server].should be_a_kind_of(Chef::ResourceDefinition)
+ defs.has_key?(:openldap_client).should eql(true)
+ defs[:openldap_client].should be_a_kind_of(Chef::ResourceDefinition)
+ end
+
+ it "should have a list of recipe files" do
+ @cookbook.recipe_files.should be_a_kind_of(Array)
+ end
+
+ it "should allow you to set the list of recipe files" do
+ @cookbook.recipe_files = [ "one", "two" ]
+ @cookbook.recipe_files.should eql(["one", "two"])
+ end
+
+ it "should have a list of recipes by name" do
+ @cookbook.recipe_files = [ "one", "two" ]
+ @cookbook.recipes.detect { |r| r == "openldap::one" }.should eql("openldap::one")
+ @cookbook.recipes.detect { |r| r == "openldap::two" }.should eql("openldap::two")
+ end
+
+ it "should take a file /path.rb, and use the filename minus rb as a recipe name" do
+ @cookbook.recipe_files = [ "/something/one.rb", "/otherthing/two.rb" ]
+ @cookbook.recipes.detect { |r| r == "openldap::one" }.should eql("openldap::one")
+ @cookbook.recipes.detect { |r| r == "openldap::two" }.should eql("openldap::two")
+ end
+
+ it "should take a file path.rb, and use the filename minus rb as a recipe name" do
+ @cookbook.recipe_files = [ "one.rb", "two.rb" ]
+ @cookbook.recipes.detect { |r| r == "openldap::one" }.should eql("openldap::one")
+ @cookbook.recipes.detect { |r| r == "openldap::two" }.should eql("openldap::two")
+ end
+
+ it "should allow you to test for a recipe with recipe?" do
+ @cookbook.recipe_files = [ "one", "two" ]
+ @cookbook.recipe?("one").should eql(true)
+ @cookbook.recipe?("shanghai").should eql(false)
+ end
+
+ it "should allow you to test for a recipe? with a fq recipe name" do
+ @cookbook.recipe_files = [ "one", "two" ]
+ @cookbook.recipe?("openldap::one").should eql(true)
+ @cookbook.recipe?("shanghai::city").should eql(false)
+ end
+
+ it "should allow you to run a recipe by name via load_recipe" do
+ @cookbook.recipe_files = Dir[File.join(COOKBOOK_PATH, "recipes", "**", "*.rb")]
+ node = Chef::Node.new
+ node.name "Julia Child"
+ recipe = @cookbook.load_recipe("openldap::gigantor", node)
+ recipe.recipe_name.should eql("gigantor")
+ recipe.cookbook_name.should eql("openldap")
+ recipe.collection[0].name.should eql("blanket")
+ end
+
+ it "should raise an ArgumentException if you try to load a bad recipe name" do
+ node = Chef::Node.new
+ node.name "Julia Child"
+ lambda { @cookbook.load_recipe("smackdown", node) }.should raise_error(ArgumentError)
+ end
+end \ No newline at end of file