|
| 1 | +# |
| 2 | +# Author:: Ian Meyer (<ianmmeyer@gmail.com>) |
| 3 | +# Copyright:: Copyright (c) 2010 Ian Meyer |
| 4 | +# License:: Apache License, Version 2.0 |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +# |
| 18 | + |
| 19 | +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper")) |
| 20 | + |
| 21 | +describe Chef::Knife::WindowsBootstrap do |
| 22 | + before(:each) do |
| 23 | + @knife = Chef::Knife::WindowsBootstrap.new |
| 24 | + @knife.config[:template_file] = File.expand_path(File.join(CHEF_SPEC_DATA, "bootstrap", "test.erb")) |
| 25 | + end |
| 26 | + |
| 27 | + it "should load the default bootstrap template" do |
| 28 | + @knife.load_template.should be_a_kind_of(String) |
| 29 | + end |
| 30 | + |
| 31 | + it "should error if template can not be found" do |
| 32 | + @knife.config[:template_file] = false |
| 33 | + @knife.config[:distro] = 'penultimate' |
| 34 | + lambda { @knife.load_template }.should raise_error |
| 35 | + end |
| 36 | + |
| 37 | + it "should load the specified template" do |
| 38 | + @knife.config[:distro] = 'fedora13-gems' |
| 39 | + lambda { @knife.load_template }.should_not raise_error |
| 40 | + end |
| 41 | + |
| 42 | + it "should return an empty run_list" do |
| 43 | + template_string = @knife.load_template(@knife.config[:template_file]) |
| 44 | + @knife.render_template(template_string).should == '{"run_list":[]}' |
| 45 | + end |
| 46 | + |
| 47 | + it "should have role[base] in the run_list" do |
| 48 | + template_string = @knife.load_template(@knife.config[:template_file]) |
| 49 | + @knife.parse_options(["-r","role[base]"]) |
| 50 | + @knife.render_template(template_string).should == '{"run_list":["role[base]"]}' |
| 51 | + end |
| 52 | + |
| 53 | + it "should have role[base] and recipe[cupcakes] in the run_list" do |
| 54 | + template_string = @knife.load_template(@knife.config[:template_file]) |
| 55 | + @knife.parse_options(["-r", "role[base],recipe[cupcakes]"]) |
| 56 | + @knife.render_template(template_string).should == '{"run_list":["role[base]","recipe[cupcakes]"]}' |
| 57 | + end |
| 58 | + |
| 59 | + it "should take the node name from ARGV" do |
| 60 | + @knife.name_args = ['barf'] |
| 61 | + @knife.name_args.first.should == "barf" |
| 62 | + end |
| 63 | + |
| 64 | +end |
0 commit comments