summaryrefslogtreecommitdiffstats
path: root/spec/unit/ssl
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-08-20 12:57:26 -0500
committerLuke Kanies <luke@madstop.com>2008-08-20 12:57:26 -0500
commitc8190421a351ed327361a5daca82441be39ce834 (patch)
tree5eae8eafafacafa817c5e890e03d1a9bcf17358d /spec/unit/ssl
parent78bc32d0153dd98fadae99dcd71d26fc97210d3c (diff)
downloadpuppet-c8190421a351ed327361a5daca82441be39ce834.tar.gz
puppet-c8190421a351ed327361a5daca82441be39ce834.tar.xz
puppet-c8190421a351ed327361a5daca82441be39ce834.zip
Fixing the String format (fixes #1522).
The string format no longer provides any support methods, which means that I had to create to_multiple_s and from_multiple_s methods on the SSL classes. I created them in the base class and tested them just in the cert class. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/ssl')
-rwxr-xr-xspec/unit/ssl/certificate.rb44
1 files changed, 34 insertions, 10 deletions
diff --git a/spec/unit/ssl/certificate.rb b/spec/unit/ssl/certificate.rb
index 34868dcd2..92b7f2cd6 100755
--- a/spec/unit/ssl/certificate.rb
+++ b/spec/unit/ssl/certificate.rb
@@ -41,6 +41,40 @@ describe Puppet::SSL::Certificate do
@class.from_s("my certificate")
end
+
+ it "should create multiple certificate instances when asked" do
+ cert1 = stub 'cert1'
+ @class.expects(:from_s).with("cert1").returns cert1
+ cert2 = stub 'cert2'
+ @class.expects(:from_s).with("cert2").returns cert2
+
+ @class.from_multiple_s("cert1\n---\ncert2").should == [cert1, cert2]
+ end
+ end
+
+ describe "when converting to a string" do
+ before do
+ @certificate = @class.new("myname")
+ end
+
+ it "should return an empty string when it has no certificate" do
+ @certificate.to_s.should == ""
+ end
+
+ it "should convert the certificate to pem format" do
+ certificate = mock 'certificate', :to_pem => "pem"
+ @certificate.content = certificate
+ @certificate.to_s.should == "pem"
+ end
+
+ it "should be able to convert multiple instances to a string" do
+ cert2 = @class.new("foo")
+ @certificate.expects(:to_s).returns "cert1"
+ cert2.expects(:to_s).returns "cert2"
+
+ @class.to_multiple_s([@certificate, cert2]).should == "cert1\n---\ncert2"
+
+ end
end
describe "when managing instances" do
@@ -84,16 +118,6 @@ describe Puppet::SSL::Certificate do
@certificate.content.should equal(certificate)
end
- it "should return an empty string when converted to a string with no certificate" do
- @certificate.to_s.should == ""
- end
-
- it "should convert the certificate to pem format when converted to a string" do
- certificate = mock 'certificate', :to_pem => "pem"
- @certificate.content = certificate
- @certificate.to_s.should == "pem"
- end
-
it "should have a :to_text method that it delegates to the actual key" do
real_certificate = mock 'certificate'
real_certificate.expects(:to_text).returns "certificatetext"