Sha256: 35d1d5c8811ac6a6eab577e86c5da4132e1ffd9347b2a799f7a9ba499c759a52

Contents?: true

Size: 708 Bytes

Versions: 2

Compression:

Stored size: 708 Bytes

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')

      model.to_json.should  == '{"id":null,"created_at":null,"updated_at":null,"name":"Ze","birth":"1986-01-23","points":200}'
    end
  end

  describe '.from_json' do
    it 'desserializes instance from json' do
      model = TestEntity.from_json('{"name":"Ze","birth":"1986-01-23","points":200}')
      model.name.should == 'Ze'
      model.birth.should == Date.new(1986, 01, 23)
      model.points.should == 200
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hari-0.0.4 spec/hari/entity/serialization_spec.rb
hari-0.0.3 spec/hari/entity/serialization_spec.rb