summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-09-08 11:56:14 -0700
committerClaire McQuin <claire@getchef.com>2014-09-08 15:21:15 -0700
commitda81fd4cfb418fa779744a0e73b80981d2313ff5 (patch)
tree0a7f849480a4d495d75ccaf2f1ed0aa3c2324495
parent4d5d368f4de2f7c117dca813f099414cdf759a75 (diff)
downloadchef-da81fd4cfb418fa779744a0e73b80981d2313ff5.tar.gz
reliably stub cert transfer tests
-rw-r--r--spec/unit/knife/bootstrap_spec.rb18
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