diff options
Diffstat (limited to 'activerecord/test/xml_serialization_test.rb')
-rw-r--r-- | activerecord/test/xml_serialization_test.rb | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/activerecord/test/xml_serialization_test.rb b/activerecord/test/xml_serialization_test.rb index 73ff354c48..61da81fe2d 100644 --- a/activerecord/test/xml_serialization_test.rb +++ b/activerecord/test/xml_serialization_test.rb @@ -9,11 +9,14 @@ class Contact < ActiveRecord::Base columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) end - column :name, :string - column :age, :integer - column :avatar, :binary - column :created_at, :datetime - column :awesome, :boolean + column :name, :string + column :age, :integer + column :avatar, :binary + column :created_at, :datetime + column :awesome, :boolean + column :preferences, :string + + serialize :preferences end class XmlSerializationTest < Test::Unit::TestCase @@ -57,7 +60,7 @@ end class DefaultXmlSerializationTest < Test::Unit::TestCase def setup - @xml = Contact.new(:name => 'aaron stack', :age => 25, :avatar => 'binarydata', :created_at => Time.utc(2006, 8, 1), :awesome => false).to_xml + @xml = Contact.new(:name => 'aaron stack', :age => 25, :avatar => 'binarydata', :created_at => Time.utc(2006, 8, 1), :awesome => false, :preferences => { :gem => 'ruby' }).to_xml end def test_should_serialize_string @@ -81,6 +84,10 @@ class DefaultXmlSerializationTest < Test::Unit::TestCase def test_should_serialize_boolean assert_match %r{<awesome type=\"boolean\">false</awesome>}, @xml end + + def test_should_serialize_yaml + assert_match %r{<preferences type=\"yaml\">--- \n:gem: ruby\n</preferences>}, @xml + end end class NilXmlSerializationTest < Test::Unit::TestCase @@ -109,6 +116,10 @@ class NilXmlSerializationTest < Test::Unit::TestCase def test_should_serialize_boolean assert_match %r{<awesome type=\"boolean\"></awesome>}, @xml end + + def test_should_serialize_yaml + assert_match %r{<preferences type=\"yaml\"></preferences>}, @xml + end end class DatabaseConnectedXmlSerializationTest < Test::Unit::TestCase |