Sha256: e406c6b1836eb1bd7b81022cc32010d068bba9178f6494581896f6ac32778198
Contents?: true
Size: 822 Bytes
Versions: 2
Compression:
Stored size: 822 Bytes
Contents
require "test_helper" require "representable/object" class ObjectTest < MiniTest::Spec Song = Struct.new(:title, :album) Album = Struct.new(:name, :songs) representer!(module: Representable::Object) do property :title property :album, instance: lambda { |fragment, *| fragment } do property :name collection :songs, instance: lambda { |fragment, *|fragment } do property :title end end # TODO: collection end let (:source) { Song.new("The King Is Dead", Album.new("Ruiner", [Song.new("In Vino Veritas II")])) } let (:target) { Song.new } it do representer.prepare(target).from_object(source) target.title.must_equal "The King Is Dead" target.album.name.must_equal "Ruiner" target.album.songs[0].title.must_equal "In Vino Veritas II" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
representable-2.1.5 | test/object_test.rb |
representable-2.1.4 | test/object_test.rb |