|
150 | 150 |
|
151 | 151 | end |
152 | 152 |
|
| 153 | + describe "render_template" do |
| 154 | + |
| 155 | + end |
| 156 | + |
| 157 | +end |
| 158 | + |
| 159 | +describe Chef::Knife::Bootstrap::TemplateHelper do |
| 160 | + before(:each) do |
| 161 | + @context = Erubis::Context.new({ |
| 162 | + :config => Hash.new |
| 163 | + }) |
| 164 | + end |
| 165 | + |
| 166 | + describe "bootstrap_version_string" do |
| 167 | + after(:each) do |
| 168 | + Chef::Config.delete :bootstrap_version |
| 169 | + end |
| 170 | + |
| 171 | + formats = { |
| 172 | + :gems => /^--version \d+\.\d+\.\d+/, |
| 173 | + :nil => '\d+\.\d+\.\d+' |
| 174 | + } |
| 175 | + |
| 176 | + context "by default" do |
| 177 | + formats.each do |sym, format| |
| 178 | + it "should return the current version of Chef for :#{sym.to_s}" do |
| 179 | + @context.bootstrap_version_string(sym).should include Chef::VERSION |
| 180 | + end |
| 181 | + |
| 182 | + it "should match the correct output format for :#{sym.to_s}" do |
| 183 | + @context.bootstrap_version_string(sym).should match format |
| 184 | + end |
| 185 | + end |
| 186 | + end |
| 187 | + |
| 188 | + context "with Chef::Config[:bootstrap_version] set" do |
| 189 | + before(:each) do |
| 190 | + @config_version = "0.9.12" |
| 191 | + Chef::Config[:bootstrap_version] = @config_version |
| 192 | + end |
| 193 | + |
| 194 | + formats.each do |sym, format| |
| 195 | + it "should return the specified bootstrap version for :#{sym.to_s}" do |
| 196 | + @context.bootstrap_version_string(sym).should include @config_version |
| 197 | + end |
| 198 | + |
| 199 | + it "should match the correct output format for :#{sym.to_s}" do |
| 200 | + @context.bootstrap_version_string(sym).should match format |
| 201 | + end |
| 202 | + end |
| 203 | + end |
| 204 | + |
| 205 | + context "with config[:prerelease] set" do |
| 206 | + before(:each) do |
| 207 | + @context[:config][:prerelease] = true |
| 208 | + end |
| 209 | + |
| 210 | + it "should return --prerelease only for :gems" do |
| 211 | + formats.each do |sym, format| |
| 212 | + version_string = @context.bootstrap_version_string(sym) |
| 213 | + version_string.should == "--prerelease" if sym == :gems |
| 214 | + version_string.should_not == "--prerelease" if sym != :gems |
| 215 | + end |
| 216 | + end |
| 217 | + end |
| 218 | + end |
153 | 219 | end |
0 commit comments