diff options
author | Matt Robinson <matt@puppetlabs.com> | 2011-02-28 16:55:18 -0800 |
---|---|---|
committer | Matt Robinson <matt@puppetlabs.com> | 2011-02-28 17:10:59 -0800 |
commit | 422399b47764e29055974ff5bad5dfcb982a8b74 (patch) | |
tree | 135a3081e806a929420ae9e13b436ef49dd81fc3 /spec | |
parent | 8cc390caa18e3b536869f0591d529d8ade76fc49 (diff) | |
download | puppet-422399b47764e29055974ff5bad5dfcb982a8b74.tar.gz puppet-422399b47764e29055974ff5bad5dfcb982a8b74.tar.xz puppet-422399b47764e29055974ff5bad5dfcb982a8b74.zip |
(#5466) Write specs for output of puppet resource
Reviewed-by: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/unit/resource_spec.rb | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index ff31b2492..eaa3d5519 100755 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -99,11 +99,11 @@ describe Puppet::Resource do end it 'should fail if strict is set and type does not exist' do - lambda { Puppet::Resource.new('foo', 'title', {:strict=>true}) }.should raise_error(ArgumentError, 'Invalid resource type foo') + lambda { Puppet::Resource.new('foo', 'title', {:strict=>true}) }.should raise_error(ArgumentError, 'Invalid resource type foo') end it 'should fail if strict is set and class does not exist' do - lambda { Puppet::Resource.new('Class', 'foo', {:strict=>true}) }.should raise_error(ArgumentError, 'Could not find declared class foo') + lambda { Puppet::Resource.new('Class', 'foo', {:strict=>true}) }.should raise_error(ArgumentError, 'Could not find declared class foo') end it "should fail if the title is a hash and the type is not a valid resource reference string" do @@ -486,19 +486,23 @@ describe Puppet::Resource do describe "when converting to puppet code" do before do - @resource = Puppet::Resource.new("one::two", "/my/file", :parameters => {:noop => true, :foo => %w{one two}}) - end - - it "should print the type and title" do - @resource.to_manifest.should be_include("one::two { '/my/file':\n") - end - - it "should print each parameter, with the value single-quoted" do - @resource.to_manifest.should be_include(" noop => 'true'") + @resource = Puppet::Resource.new("one::two", "/my/file", + :parameters => { + :noop => true, + :foo => %w{one two}, + :ensure => 'present', + } + ) end - it "should print array values appropriately" do - @resource.to_manifest.should be_include(" foo => ['one','two']") + it "should align, sort and add trailing commas to attributes with ensure first" do + @resource.to_manifest.should == <<-HEREDOC.gsub(/^\s{8}/, '').gsub(/\n$/, '') + one::two { '/my/file': + ensure => 'present', + foo => ['one', 'two'], + noop => 'true', + } + HEREDOC end end |