diff options
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index 5e22a41f4e..41fc57338e 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -366,7 +366,11 @@ describe Chef::Knife::Bootstrap do before do Chef::Config[:trusted_certs_dir] = trusted_certs_dir IO.stub(:read).and_call_original - IO.stub(:read).with("/etc/chef/validation.pem").and_return("-----BEGIN...") + IO.stub(:read).with("/etc/chef/validation.pem").and_return("") + end + + def certificates + Dir[File.join(trusted_certs_dir, "*.{crt,pem}")] end it "creates /etc/chef/trusted_certs" do @@ -374,13 +378,13 @@ describe Chef::Knife::Bootstrap do end it "copies the certificates in the directory" do - match_str = "" - Dir[File.join(trusted_certs_dir, '*')].each do |cert| - match_str << "cat > /etc/chef/trusted_certs/#{File.basename(cert)} <<'EOP'\n" + - "#{IO.read(File.expand_path(cert))}\n" + - "EOP\n" + certificates.each do |cert| + IO.should_receive(:read).with(File.expand_path(cert)) + end + + certificates.each do |cert| + rendered_template.should match(%r{cat > /etc/chef/trusted_certs/#{File.basename(cert)} <<'EOP'}) end - rendered_template.should include(match_str) end it "doesn't create /etc/chef/trusted_certs if :trusted_certs_dir is empty" do |