Sha256: b3cf9d2038c498ea070d7a95b68bf25baffc1816d0bdd35141c1e25c6cfd8794
Contents?: true
Size: 1 KB
Versions: 25
Compression:
Stored size: 1 KB
Contents
require 'test_helper' class SerializeDeserializeTest < BaseTest subject { Struct.new(:song).new.extend(representer) } describe "deserialize" do representer! do property :song, :instance => lambda { |fragment, *| fragment.to_s.upcase }, :prepare => lambda { |fragment, *| fragment }, # TODO: allow false. :deserialize => lambda { |object, fragment, args| "#{object} #{fragment} #{args.inspect}" } end it { subject.from_hash({"song" => Object}, {:volume => 9}).song.must_equal "OBJECT Object {:volume=>9}" } end describe "serialize" do representer! do property :song, :representable => true, :prepare => lambda { |fragment, *| fragment }, # TODO: allow false. :serialize => lambda { |object, args| "#{object} #{args.inspect}" } end before { subject.song = "Arrested In Shanghai" } it { subject.to_hash({:volume => 9}).must_equal({"song"=>"Arrested In Shanghai {:volume=>9}"}) } end end
Version data entries
25 entries across 25 versions & 1 rubygems