Sha256: 3cb17455e60455e4770d68e1c3f0715a7819b7010273655b85fc4ccc2b39bf70
Contents?: true
Size: 1.66 KB
Versions: 3
Compression:
Stored size: 1.66 KB
Contents
require File.join(File.dirname(__FILE__), 'helper') class AdapterTest < Test::Unit::TestCase context 'Serial key resource' do setup do class ::User include DataMapper::Resource property :id, Serial property :name, String property :age, Integer end @user = User.create(:name => 'Joe', :age => 22) end teardown do # Why doesn't DM::Resource#destroy exist? repository = DataMapper.repository(:default) repository.adapter.delete( DataMapper::Query.new(repository, ::User, {}) ) end should 'assign id to attributes' do item = User.create assert_kind_of User, item assert_not_nil item.id end should 'get an item' do assert_equal @user, User.get(@user.id) end should 'get items' do assert_equal 1, User.all.size end should 'destroy item' do assert @user.destroy assert_equal 0, User.all.size end should 'update item' do @user.name = 'Woot' assert @user.save assert_equal 'Woot', User.get(@user.id).name end end context 'Compound key resource' do setup do class ::User include DataMapper::Resource property :name, String, :key => true property :age, Integer, :key => true end @user = User.create(:name => 'Joe', :age => 22) end teardown do # Why doesn't DM::Resource#destroy exist? repository = DataMapper.repository(:default) repository.adapter.delete( DataMapper::Query.new(repository, ::User, {}) ) end should 'get an item' do assert_equal @user, User.get(*@user.key) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shanna-dm-tokyo-cabinet-adapter-0.1.4 | test/test_adapter.rb |
shanna-dm-tokyo-cabinet-adapter-0.1.5 | test/test_adapter.rb |
shanna-dm-tokyo-cabinet-adapter-0.1.6 | test/test_adapter.rb |