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