summaryrefslogtreecommitdiffstats
path: root/spec/unit/type/ssh_authorized_key.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/type/ssh_authorized_key.rb')
-rwxr-xr-xspec/unit/type/ssh_authorized_key.rb39
1 files changed, 31 insertions, 8 deletions
diff --git a/spec/unit/type/ssh_authorized_key.rb b/spec/unit/type/ssh_authorized_key.rb
index 9a2389eef..db389864e 100755
--- a/spec/unit/type/ssh_authorized_key.rb
+++ b/spec/unit/type/ssh_authorized_key.rb
@@ -89,13 +89,36 @@ describe ssh_authorized_key do
@class.attrtype(:target).should == :property
end
- it "should raise an error when neither user nor target is given" do
- proc do
- @class.new(
- :name => "Test",
- :key => "AAA",
- :type => "ssh-rsa",
- :ensure => :present)
- end.should raise_error(Puppet::Error)
+ describe "when neither user nor target is specified" do
+ it "should raise an error" do
+ proc do
+ @class.create(
+ :name => "Test",
+ :key => "AAA",
+ :type => "ssh-rsa",
+ :ensure => :present)
+ end.should raise_error(Puppet::Error)
+ end
+ end
+
+ describe "when both target and user are specified" do
+ it "should use target" do
+ resource = @class.create(
+ :name => "Test",
+ :user => "root",
+ :target => "/tmp/blah")
+ resource.should(:target).should == "/tmp/blah"
+ end
+ end
+
+
+ describe "when user is specified" do
+ it "should determine target" do
+ resource = @class.create(
+ :name => "Test",
+ :user => "root")
+ target = File.expand_path("~root/.ssh/authorized_keys")
+ resource.should(:target).should == target
+ end
end
end