Adding alias to get for find

This commit is contained in:
Sam Lown 2010-06-07 13:56:39 +02:00
parent c06907fe58
commit 7b40042087
2 changed files with 9 additions and 2 deletions

View file

@ -56,6 +56,7 @@ module CouchRest
nil
end
end
alias :find :get
# Load a document from the database by id
# An exception will be raised if the document isn't found
@ -72,6 +73,7 @@ module CouchRest
doc = db.get id
create_from_database(doc)
end
alias :find! :get!
end

View file

@ -328,15 +328,20 @@ describe "ExtendedDocument" do
foundart = Article.get @art.id
foundart.title.should == "All About Getting"
end
it "should load and instantiate with find" do
foundart = Article.find @art.id
foundart.title.should == "All About Getting"
end
it "should return nil if `get` is used and the document doesn't exist" do
foundart = Article.get 'matt aimonetti'
foundart.should be_nil
end
it "should raise an error if `get!` is used and the document doesn't exist" do
lambda{foundart = Article.get!('matt aimonetti')}.should raise_error
end
it "should raise an error if `find!` is used and the document doesn't exist" do
lambda{foundart = Article.find!('matt aimonetti')}.should raise_error
end
end
describe "getting a model with a subobjects array" do