summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-09-08 16:17:58 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-09-08 16:17:58 -0700
commit4bda0b53c7b30814a2c8f97455c9362b1de67f2a (patch)
tree45c27590c72a374ac2845f7007f19cc3af96ccc7 /spec
parentfb9034731ddae41f1009745eb8eb1ea53aa05cfb (diff)
parent50fd9b77cdb2346ec0b760364841abd4eb6f23ff (diff)
downloadpuppet-4bda0b53c7b30814a2c8f97455c9362b1de67f2a.tar.gz
puppet-4bda0b53c7b30814a2c8f97455c9362b1de67f2a.tar.xz
puppet-4bda0b53c7b30814a2c8f97455c9362b1de67f2a.zip
Merge remote branch 'paul/ticket/next/4570' into next
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/util/zaml_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/unit/util/zaml_spec.rb b/spec/unit/util/zaml_spec.rb
index 4de57e6d3..14cf94f36 100644
--- a/spec/unit/util/zaml_spec.rb
+++ b/spec/unit/util/zaml_spec.rb
@@ -34,5 +34,30 @@ describe "Pure ruby yaml implementation" do
lambda { YAML.load(o.to_yaml) }.should_not raise_error
end
}
+
+ it "should emit proper labels and backreferences for common objects" do
+ # Note: this test makes assumptions about the names ZAML chooses
+ # for labels.
+ x = [1, 2]
+ y = [3, 4]
+ z = [x, y, x, y]
+ z.to_yaml.should == "--- \n - &id001\n - 1\n - 2\n - &id002\n - 3\n - 4\n - *id001\n - *id002"
+ z2 = YAML.load(z.to_yaml)
+ z2.should == z
+ z2[0].should equal(z2[2])
+ z2[1].should equal(z2[3])
+ end
+
+ it "should emit proper labels and backreferences for recursive objects" do
+ x = [1, 2]
+ x << x
+ x.to_yaml.should == "--- &id001\n \n - 1\n - 2\n - *id001"
+ x2 = YAML.load(x.to_yaml)
+ x2.should be_a(Array)
+ x2.length.should == 3
+ x2[0].should == 1
+ x2[1].should == 2
+ x2[2].should equal(x2)
+ end
end