diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-05-01 16:59:51 +0200 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-05-02 09:08:00 +1000 |
| commit | a1c0ae0fe3c4bef6f21240c4d0a8da985cc7c8af (patch) | |
| tree | 089ead1cdd48bb6dd21e7abe07acc7ab041b50dc /spec/unit/network | |
| parent | bf054e1b2c0117135de5f54421c112523e83a88c (diff) | |
| download | puppet-a1c0ae0fe3c4bef6f21240c4d0a8da985cc7c8af.tar.gz puppet-a1c0ae0fe3c4bef6f21240c4d0a8da985cc7c8af.tar.xz puppet-a1c0ae0fe3c4bef6f21240c4d0a8da985cc7c8af.zip | |
Fix #2218 - Ruby YAML bug prevents reloading catalog in puppetd
Because of ruby bug:
http://rubyforge.org/tracker/?group_id=426&atid=1698&func=detail&aid=8886
and
http://redmine.ruby-lang.org/issues/show/1331
YAML dump of hashes using ruby objects as keys is incorrect leading
to an error when deserializing the YAML in puppetd.
The error is easy to correct by a post-process fix-up of
the generated YAML, which transforms:
&id004 !ruby/object:Puppet::Relationship ?
to the correct:
? &id004 !ruby/object:Puppet::Relationship
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/network')
| -rwxr-xr-x | spec/unit/network/formats.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/unit/network/formats.rb b/spec/unit/network/formats.rb index 0e21fefa7..b472cbf65 100755 --- a/spec/unit/network/formats.rb +++ b/spec/unit/network/formats.rb @@ -28,12 +28,29 @@ describe "Puppet Network Format" do @yaml.render(instance).should == "foo" end + it "should fixup generated yaml on render" do + instance = mock 'instance', :to_yaml => "foo" + + @yaml.expects(:fixup).with("foo").returns "bar" + + @yaml.render(instance).should == "bar" + end + it "should render multiple instances by calling 'to_yaml' on the array" do instances = [mock('instance')] instances.expects(:to_yaml).returns "foo" @yaml.render_multiple(instances).should == "foo" end + it "should fixup generated yaml on render" do + instances = [mock('instance')] + instances.stubs(:to_yaml).returns "foo" + + @yaml.expects(:fixup).with("foo").returns "bar" + + @yaml.render(instances).should == "bar" + end + it "should intern by calling 'YAML.load'" do text = "foo" YAML.expects(:load).with("foo").returns "bar" @@ -45,6 +62,10 @@ describe "Puppet Network Format" do YAML.expects(:load).with("foo").returns "bar" @yaml.intern_multiple(String, text).should == "bar" end + + it "should fixup incorrect yaml to correct" do + @yaml.fixup("&id004 !ruby/object:Puppet::Relationship ?").should == "? &id004 !ruby/object:Puppet::Relationship" + end end it "should include a marshal format" do |
