diff options
| author | Luke Kanies <luke@madstop.com> | 2009-04-09 17:43:17 -0500 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-04-22 14:39:37 +1000 |
| commit | 7a91e1f5c03ed02eed4c45fddd740b899650bf36 (patch) | |
| tree | fd6b7ec003f1e04384ca164a742e3fd373e40cba /spec/unit/util | |
| parent | c30ede56f576aa6032221ed45510f50b0303ef7a (diff) | |
| download | puppet-7a91e1f5c03ed02eed4c45fddd740b899650bf36.tar.gz puppet-7a91e1f5c03ed02eed4c45fddd740b899650bf36.tar.xz puppet-7a91e1f5c03ed02eed4c45fddd740b899650bf36.zip | |
Changing rails value serialization to deal with booleans
The database was automatically converting booleans
to strings, and value comparison was not working correctly
as a result.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/util')
| -rw-r--r-- | spec/unit/util/reference_serializer.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/unit/util/reference_serializer.rb b/spec/unit/util/reference_serializer.rb new file mode 100644 index 000000000..c3da45a36 --- /dev/null +++ b/spec/unit/util/reference_serializer.rb @@ -0,0 +1,52 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' +require 'puppet/util/rails/reference_serializer' + +class SerializeTester + include Puppet::Util::ReferenceSerializer +end + +describe Puppet::Util::ReferenceSerializer do + before do + @tester = SerializeTester.new + end + + describe "when serializing" do + it "should yaml-dump resource references" do + ref = Puppet::Parser::Resource::Reference.new(:type => "file", :title => "/foo") + @tester.serialize_value(ref).should =~ /^---/ + end + + it "should convert the boolean 'true' into the string 'true'" do + @tester.serialize_value(true).should == "true" + end + + it "should convert the boolean 'false' into the string 'false'" do + @tester.serialize_value(false).should == "false" + end + + it "should return all other values" do + @tester.serialize_value("foo").should == "foo" + end + end + + describe "when unserializing" do + it "should yaml-load values that look like yaml" do + yaml = YAML.dump(%w{a b c}) + @tester.unserialize_value(yaml).should == %w{a b c} + end + + it "should convert the string 'true' into the boolean 'true'" do + @tester.unserialize_value("true").should == true + end + + it "should convert the string 'false' into the boolean 'false'" do + @tester.unserialize_value("false").should == false + end + + it "should return all other values" do + @tester.unserialize_value("foo").should == "foo" + end + end +end |
