From: Daniel Pittman <[email protected]> We replace it with an instance of the actual resource we are testing, which reduces the number of ways this code is tied to the specific implementation.
Reviewed-By: Nick Lewis <[email protected]> --- spec/unit/provider/host/parsed_spec.rb | 1 + .../provider/ssh_authorized_key/parsed_spec.rb | 44 ++++++++------------ 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/spec/unit/provider/host/parsed_spec.rb b/spec/unit/provider/host/parsed_spec.rb index 3ed4799..048d77b 100755 --- a/spec/unit/provider/host/parsed_spec.rb +++ b/spec/unit/provider/host/parsed_spec.rb @@ -1,6 +1,7 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') +require 'shared_behaviours/all_parsedfile_providers' require 'puppet_spec/files' diff --git a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb index 6d67ee3..7a1bd77 100755 --- a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +++ b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb @@ -1,15 +1,13 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') - +require 'shared_behaviours/all_parsedfile_providers' require 'puppet_spec/files' -require 'puppettest/fakes' provider_class = Puppet::Type.type(:ssh_authorized_key).provider(:parsed) describe provider_class do include PuppetSpec::Files - include PuppetTest before :each do @sshauthkey_class = Puppet::Type.type(:ssh_authorized_key) @@ -25,15 +23,13 @@ describe provider_class do end def mkkey(args) - fakeresource = fakeresource(:ssh_authorized_key, args[:name]) - fakeresource.stubs(:should).with(:user).returns @user - fakeresource.stubs(:should).with(:target).returns @keyfile - - key = @provider.new(fakeresource) + args[:target] = @keyfile + args[:user] = @user + resource = Puppet::Type.type(:ssh_authorized_key).new(args) + key = @provider.new(resource) args.each do |p,v| key.send(p.to_s + "=", v) end - key end @@ -50,30 +46,24 @@ describe provider_class do it "should be able to generate a basic authorized_keys file" do - key = mkkey( - { - :name => "Just Testing", - :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", - :type => "ssh-dss", - :ensure => :present, - - :options => [:absent] - }) + key = mkkey(:name => "Just Testing", + :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", + :type => "ssh-dss", + :ensure => :present, + :options => [:absent] + ) genkey(key).should == "ssh-dss AAAAfsfddsjldjgksdflgkjsfdlgkj Just Testing\n" end it "should be able to generate a authorized_keys file with options" do - key = mkkey( - { - :name => "root@localhost", - :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", - :type => "ssh-rsa", - :ensure => :present, - - :options => ['from="192.168.1.1"', "no-pty", "no-X11-forwarding"] - }) + key = mkkey(:name => "root@localhost", + :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", + :type => "ssh-rsa", + :ensure => :present, + :options => ['from="192.168.1.1"', "no-pty", "no-X11-forwarding"] + ) genkey(key).should == "from=\"192.168.1.1\",no-pty,no-X11-forwarding ssh-rsa AAAAfsfddsjldjgksdflgkjsfdlgkj root@localhost\n" end -- 1.7.4.1 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
