Sha256: 47471021210592463e3b472d9af859b545029d0ad1f1cda3998aa3556f078e3d
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
require File.join(File.dirname(__FILE__), 'helper') class QueryTest < Test::Unit::TestCase context 'Resource' do setup do class ::User include DataMapper::Resource property :id, Serial property :name, String property :age, Integer end @joe = User.create(:name => 'Joe', :age => 11) @jack = User.create(:name => 'Jack', :age => 22) @john = User.create(:name => 'John', :age => 33) end teardown do # Why doesn't DM::Model#destroy exist? repository = DataMapper.repository(:default) repository.adapter.delete( DataMapper::Query.new(repository, ::User, {}) ) end should 'get items' do assert_equal 3, User.all.size end should 'get items with sring conditions' do User.create(:name => 'John', :age => 44) assert_equal 2, User.all(:name => 'John').size end should 'get items with integer equality conditions' do User.create(:name => 'Fred', :age => 33) assert_equal 2, User.all(:age => 33).size end should 'get items with integer range conditions' do User.create(:name => 'Fred', :age => 33) assert_equal 3, User.all(:age.gte => 22, :age.lte => 34).size end should 'order items by string' do users = [@jack, @joe, @john] assert_equal users, User.all(:order => [:name.asc]) assert_equal users.reverse, User.all(:order => [:name.desc]) end should 'order items by integer' do users = [@joe, @jack, @john] assert_equal users, User.all(:order => [:age.asc]) assert_equal users.reverse, User.all(:order => [:age.desc]) end should 'limit items' do assert_equal 2, User.all(:limit => 2).size end end end # QueryTest
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shanna-dm-tokyo-cabinet-adapter-0.1.6 | test/test_query.rb |