Sha256: 913a7a3b47f8b581f2d76f371691b1457263eaed5a6a6c7c5fafd69be0768c03
Contents?: true
Size: 1.87 KB
Versions: 5
Compression:
Stored size: 1.87 KB
Contents
require File.dirname(__FILE__) + '/../test_helper' class XmlSerializerAttributeWithEnumerationTest < ActiveRecord::TestCase def setup @red = create_color(:name => 'red') @car = create_car(:name => 'Ford Mustang', :color => @red) @attribute = ActiveRecord::XmlSerializer::Attribute.new('color', @car) end def test_should_have_a_string_type assert_equal :string, @attribute.type end def test_should_use_enumerator assert_equal 'red', @attribute.value end end class XmlSerializerAttributeWithNilEnumerationTest < ActiveRecord::TestCase def setup @red = create_color(:name => 'red') @car = create_car(:name => 'Ford Mustang', :color => nil) @attribute = ActiveRecord::XmlSerializer::Attribute.new('color', @car) end def test_should_have_a_string_type assert_equal :string, @attribute.type end def test_should_use_nil assert_nil @attribute.value end end class XmlSerializerAttributeWithoutEnumerationTest < ActiveRecord::TestCase def setup @red = create_color(:name => 'red') @car = create_car(:name => 'Ford Mustang', :color => @red) @attribute = ActiveRecord::XmlSerializer::Attribute.new('id', @car) end def test_should_use_column_type assert_equal :integer, @attribute.type end def test_should_use_attribute_value assert_equal @car.id, @attribute.value end end class XmlSerializerTest < ActiveRecord::TestCase def setup @red = create_color(:name => 'red') @car = create_car(:name => 'Ford Mustang', :color => @red) end def test_should_be_able_to_convert_to_xml expected = <<-eos <?xml version="1.0" encoding="UTF-8"?> <car> <color>red</color> <feature-id type="integer" nil="true"></feature-id> <feature-type nil="true"></feature-type> <id type="integer">#{@car.id}</id> <name>Ford Mustang</name> </car> eos assert_equal expected, @car.to_xml end end
Version data entries
5 entries across 5 versions & 3 rubygems