Sha256: 8cac4dfe4a10a870fb1303e8ed9d0d9ff45d6a026a184016d52ea5b007198ea4
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'test_helper' require 'representable/json' class DeserializeTest < BaseTest class AlbumContract < Reform::Form self.representer_class.class_eval do include Representable::JSON end def deserialize_method :from_json end property :title validates :title, :presence => true, :length => {:minimum => 3} property :hit do property :title validates :title, :presence => true end property :band do # yepp, people do crazy stuff like that. validates :label, :presence => true property :label do property :name validates :name, :presence => true end end end let (:album) { Album.new(nil, Song.new, [Song.new, Song.new], Band.new(Label.new("Fat Wreck")) ) } subject { AlbumContract.new(album) } let (:json) { '{"hit":{"title":"Sacrifice"},"title":"Second Heat","songs":[{"title":"Heart Of A Lion"}],"band":{"label":{"name":"Fat Wreck"}}}' } it { subject.validate(json) subject.band.label.name.must_equal "Fat Wreck" } end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reform-1.1.0 | test/deserialize_test.rb |