0
@@ -3,7 +3,7 @@ require Pathname(__FILE__).dirname.parent.expand_path + 'lib/couchdb_adapter'
0
include DataMapper::Resource
0
def self.default_repository_name
0
@@ -11,14 +11,14 @@ class User
0
property :id, String, :key => true, :field => :_id
0
property :rev, String, :field => :_rev
0
property :wealth, Float
0
property :created_at, DateTime
0
property :created_on, Date
0
# creates methods for accessing stored/indexed views in the CouchDB database
0
@@ -32,17 +32,17 @@ describe "DataMapper::Adapters::CouchdbAdapter" do
0
@adapter.send(:http_put, "/users/")
0
@adapter.send(:http_delete, "/users/")
0
it "should create a record" do
0
user.save.should == true
0
user.id.should_not == nil
0
it "should get a record" do
0
created_user = new_user
0
@@ -51,7 +51,7 @@ describe "DataMapper::Adapters::CouchdbAdapter" do
0
user.name.should == "Jamie"
0
it "should update a record" do
0
created_user = new_user
0
@@ -63,28 +63,28 @@ describe "DataMapper::Adapters::CouchdbAdapter" do
0
user.age.should == created_user.age
0
user.id.should == created_user.id
0
it "should destroy a record" do
0
created_user = new_user
0
created_user.destroy.should == true
0
it "should get all records" do
0
User.all.size.should == 3
0
it "should get records by eql matcher" do
0
new_user(:name => "John", :age => 50).save
0
User.all(:name => "John").size.should == 1
0
User.all(:age => 50).size.should == 1
0
User.all(:wealth => 11.5).size.should == 4
0
it "should get records by not matcher" do
0
User.all(:age.not => 50).size.should == 3
0
it "should get records by gt matcher" do
0
User.all(:age.gt => 50).size.should == 3
0
@@ -92,26 +92,26 @@ describe "DataMapper::Adapters::CouchdbAdapter" do
0
it "should get records by gte matcher" do
0
User.all(:age.gte => 50).size.should == 4
0
it "should get records by lt matcher" do
0
User.all(:age.lt => 50).size.should == 0
0
it "should get records by lte matcher" do
0
User.all(:age.lte => 50).size.should == 1
0
it "should get records by the like matcher" do
0
User.all(:name.like => "Jo").size.should == 0
0
User.all(:name.like => "Jo%").size.should == 1
0
User.all(:name.like => /^Jam/).size.should == 2
0
it "should get records with multiple matchers" do
0
new_user(:name => "John", :age => 30).save
0
User.all(:name => "John", :age.lt => 50).size.should == 1
0
it "should order records" do
0
new_user(:name => "Aaron", :age => 30).save
0
new_user(:name => "Aaron").save
0
@@ -121,34 +121,34 @@ describe "DataMapper::Adapters::CouchdbAdapter" do
0
users[0].age.should == 30
0
users[1].age.should == 67
0
it "should handle DateTime" do
0
User[user.id].created_at.should == time
0
it "should handle Date" do
0
User[user.id].created_on.should == date
0
it "should be able to call stored views" do
0
User.by_name.first.should == User.all(:order => [:name]).first
0
User.by_age.first.should == User.all(:order => [:age]).first
0
view = Net::HTTP::Put.new("/users/_design/users")
0
view["content-type"] = "text/javascript"
0
- "language" => "text/javascript",
0
+ "language" => "text/javascript",
0
"by_name" => "function(doc) { if(doc._id.charAt(0) != '_') { map(doc.name, doc); } }",
0
"by_age" => "function(doc) { if(doc._id.charAt(0) != '_') { map(doc.age, doc); } }"
0
@@ -157,11 +157,11 @@ describe "DataMapper::Adapters::CouchdbAdapter" do
0
def new_user(options = {})
0
default_options = { :name => "Jamie", :age => 67, :wealth => 11.5 }
0
default_options.merge!(options)
0
User.new(default_options)
0
\ No newline at end of file
Comments
No one has commented yet.