Permalink
Browse files

Fixed some bugs.

  • Loading branch information...
1 parent 285a8f2 commit e2191d59db28f2d9e75aa1ef8c72fad0f947d67a @genki genki committed Apr 12, 2009
View
@@ -27,7 +27,6 @@ spec = Gem::Specification.new do |s|
s.add_dependency('dm-core', '>= 1.0.9')
s.require_path = 'lib'
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
-
end
Rake::GemPackageTask.new(spec) do |pkg|
@@ -52,6 +51,11 @@ task :gemspec do
end
end
+desc "Run specs"
+task :spec do
+ sh "jruby -S spec --color spec"
+end
+
desc 'Package and upload the release to rubyforge.'
task :release => :package do |t|
require 'rubyforge'
@@ -77,3 +81,5 @@ task :release => :package do |t|
puts "Releasing #{GEM_NAME} v. #{GEM_VERSION}"
rf.add_release RUBYFORGE_PROJECT, GEM_NAME, GEM_VERSION, *files
end
+
+task :default => :spec
@@ -7,6 +7,7 @@
Merb::BootLoader.before_app_loads do
# require code that must be loaded before the application
+ require File.join(%w(dm-datastore-adapter datastore-adapter))
end
Merb::BootLoader.after_app_loads do
@@ -58,7 +58,7 @@ def read_many(query)
Collection.new(query) do |collection|
iter.each do |entity|
collection.load(query.fields.map do |property|
- property.typecast(ds_get(entity, property.field)))
+ property.typecast(ds_get(entity, property.field))
end)
end
end
@@ -73,7 +73,7 @@ def read_one(query)
DS::Service.prepare(q).asSingleEntity
end
query.model.load(query.fields.map do |property|
- property.typecast(ds_get(entity, property.field)))
+ property.typecast(ds_get(entity, property.field))
end)
end
@@ -188,11 +188,13 @@ def ds_get(entity, name)
def ds_set(entity, name, value)
if value.is_a?(String) && value.length >= 500
- entity.set_property(name.to_s, DS::Text.new(value)
+ entity.set_property(name.to_s, DS::Text.new(value))
else
entity.set_property(name.to_s, value)
end
end
end
+
+ DatastoreAdapter = DataStoreAdapter
end
end
@@ -1,7 +1,35 @@
require File.dirname(__FILE__) + '/spec_helper'
describe "dm-datastore-adapter" do
- it "should do nothing" do
- true.should == true
+ class ::Person
+ include DataMapper::Resource
+ def self.default_repository_name; :datastore end
+ property :id, Serial
+ property :name, String
+ property :age, Integer
+ property :weight, Float
+ property :created_at, DateTime
+ property :created_on, Date
+ belongs_to :company
+ end
+
+ class ::Company
+ include DataMapper::Resource
+ def self.default_repository_name; :datastore end
+ property :id, Serial
+ property :name, String
+ has n, :users
+ end
+
+ before do
+ @person = Person.new(:name => 'Jon', :age => 40, :weight => 100)
+ end
+
+ it "should build person" do
+ @person.should_not be_nil
+ end
+
+ it "should save person successfully" do
+ @person.save.should be_true
end
end
View
@@ -1,6 +1,11 @@
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
require 'rubygems'
-dependency "dm-core"
-dependency "dm-aggregates"
-dependency "dm-validations"
+require 'dm-core'
+require 'dm-aggregates'
+require 'dm-types'
+require 'dm-datastore-adapter/datastore-adapter'
+
+DataMapper.setup(:datastore,
+ :adapter => :datastore,
+ :database => 'sample')

0 comments on commit e2191d5

Please sign in to comment.