diff --git a/lib/couchrest/mixins/document_queries.rb b/lib/couchrest/mixins/document_queries.rb index b19442e..e40ccb6 100644 --- a/lib/couchrest/mixins/document_queries.rb +++ b/lib/couchrest/mixins/document_queries.rb @@ -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 diff --git a/spec/couchrest/extended_doc_spec.rb b/spec/couchrest/extended_doc_spec.rb index c2712d6..96786da 100644 --- a/spec/couchrest/extended_doc_spec.rb +++ b/spec/couchrest/extended_doc_spec.rb @@ -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