Sha256: 9eee0f88e0ba4e45660ed9b76f6452691c58362223f62e20ccc6d1047d20eaff

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

describe Hari::Entity::Repository do

  specify '.create, .find' do
    model = TestEntity.create(name: 'Ze', birth: '2012-04-20', points: '300')
    model.id.should be

    found = TestEntity.find(model.id)
    found.birth.year.should == 2012
    found.birth.month.should == 4
    found.birth.day.should == 20
    found.points.should == 300
    found.name.should == 'Ze'

    model2 = TestEntity.create(name: 'Jo', birth: '2009-03-21', points: '404')

    founds = TestEntity.find(model.id, model2.id)
    founds.size.should == 2

    model2.update_attributes birth: '2001-01-01', points: '403', friends_ids: [1, 3, 4]

    found = TestEntity.find(model2.id)
    found.birth.year.should eq(2001)
    found.birth.month.should eq(1)
    found.birth.day.should eq(1)
    found.points.should eq(403)
    found.friends_ids.should eq [1, 3, 4]

    found.update_attributes friends_ids: [4, 5, 6]

    TestEntity.find(found.id).friends_ids.should eq [4, 5, 6]

    found.update_attribute :name, 'Joe'

    TestEntity.find(found.id).name.should eq('Joe')
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hari-0.0.5 spec/hari/entity/repository_spec.rb