Sha256: d7da63a606aaafb779dae0b995649c65dcca6bc045118e962b76671a9319e101
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require 'spec_helper' describe Hari::Entity::Serialization do describe '#to_json' do it 'serializes instance to json' do model = TestEntity.new(name: 'Ze', birth: Date.new(1986, 01, 23), points: '200', preferences: { soccer: 100, rugby: 30 }, friends_ids: [1, 2, 3]) model.to_json.should == '{"id":null,"created_at":null,"updated_at":null,' + '"name":"Ze","country":"US","birth":"1986-01-23","points":200,' + '"preferences":{"soccer":100,"rugby":30},"friends_ids":[1,2,3],"male":true}' end end describe '.from_json' do it 'desserializes instance from json' do model = TestEntity.from_json('{"name":"Ze","birth":"1986-01-23","points":200,' + '"preferences":{"soccer":100,"rugby":30},"friends_ids":[1,2,3],"male":true}') model.name.should == 'Ze' model.birth.should == Date.new(1986, 01, 23) model.points.should == 200 model.preferences.should eq('soccer' => 100, 'rugby' => 30) model.friends_ids.should eq [1, 2, 3] model.male.should be_true model.male?.should be_true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hari-0.0.5 | spec/hari/entity/serialization_spec.rb |