Sha256: f3e2988a84e313a11c460536715ba334eda19286863780f4d6ac6b1c908464c0
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
require File.dirname(__FILE__) + '/test_helper' require File.dirname(__FILE__) + '/../lib/sweat_shop' class YamlSerializerTest < Test::Unit::TestCase class UnderTest attr_accessor :name, :address, :city, :state, :zip, :id def ==(other) ![:name, :address, :city, :state, :zip, :id].map{|a| return self.send(a) == other.send(a)}.include?(false) end end def setup @under_test = UnderTest.new @under_test.id = 87 @under_test.name = "YamlTest" @under_test.address = "555 Rock Ridge Road" @under_test.city = "Rock Ridge" @under_test.state = "Texas" @under_test.zip = "90210" end test "should properly serialize a simple data structure" do dump = SweatShop::Serializers::YamlSerializer.serialize([{:foo => "bar"}, 23, 87, %w{doug cathy connor tommy}]) assert_equal [{:foo => "bar"}, 23, 87, %w{doug cathy connor tommy}].to_yaml, dump end test "should be able to serialize an arbitrary class" do dump = SweatShop::Serializers::YamlSerializer.serialize(@under_test) assert_equal @under_test.to_yaml, dump end test "should be able to deserialize a simple data structure" do assert_equal [{:foo => "bar"}, 23, 87, %w{doug cathy connor tommy}], SweatShop::Serializers::YamlSerializer.deserialize("--- \n- :foo: bar\n- 23\n- 87\n- - doug\n - cathy\n - connor\n - tommy\n") end test "should be able to deserialize an arbitrary class" do assert_equal @under_test, SweatShop::Serializers::YamlSerializer.deserialize(@under_test.to_yaml) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
netinlet-sweat_shop-1.1.0 | test/test_yaml_serializer.rb |
netinlet-sweat_shop-1.1.1 | test/test_yaml_serializer.rb |