summaryrefslogtreecommitdiffstats
path: root/spec/unit/resource
diff options
context:
space:
mode:
authorLuke Kanies <luke@puppetlabs.com>2011-03-25 11:28:13 -0700
committerLuke Kanies <luke@puppetlabs.com>2011-03-25 14:31:27 -0700
commitda082d500e1f1192dbc987483d753d93b5698094 (patch)
tree7ea0886f5d12c29ad653224e8eed68edbf99abbd /spec/unit/resource
parent4196699f5fbb90ceecbb709c8502622eaad39062 (diff)
downloadpuppet-da082d500e1f1192dbc987483d753d93b5698094.tar.gz
puppet-da082d500e1f1192dbc987483d753d93b5698094.tar.xz
puppet-da082d500e1f1192dbc987483d753d93b5698094.zip
Fixed #6850 - Clean up ResourceType#to_pson
There's no value in including the code when we convert a resource type to JSON, since you can't convert it back again, so this removes it. I also cleaned up a few of the other attributes which were producing unnecessary information. Signed-off-by: Luke Kanies <luke@puppetlabs.com> Reviewed-by: Daniel Pittman <daniel@puppetlabs.com>
Diffstat (limited to 'spec/unit/resource')
-rwxr-xr-xspec/unit/resource/type_spec.rb22
1 files changed, 17 insertions, 5 deletions
diff --git a/spec/unit/resource/type_spec.rb b/spec/unit/resource/type_spec.rb
index e9c203526..41b5554d9 100755
--- a/spec/unit/resource/type_spec.rb
+++ b/spec/unit/resource/type_spec.rb
@@ -55,12 +55,24 @@ describe Puppet::Resource::Type do
double_convert.arguments.should == {"one" => nil, "two" => "foo"}
end
- it "should include any extra attributes" do
- @type.file = "/my/file"
- @type.line = 50
+ it "should not include arguments if none are present" do
+ @type.to_pson["arguments"].should be_nil
+ end
+
+ [:line, :doc, :file, :parent].each do |attr|
+ it "should include #{attr} when set" do
+ @type.send(attr.to_s + "=", "value")
+ double_convert.send(attr).should == "value"
+ end
+
+ it "should not include #{attr} when not set" do
+ @type.to_pson[attr.to_s].should be_nil
+ end
+ end
- double_convert.file.should == "/my/file"
- double_convert.line.should == 50
+ it "should not include docs if they are empty" do
+ @type.doc = ""
+ @type.to_pson["doc"].should be_nil
end
end