spec/couchrest/persistence_spec.rb in couchrest_model-1.0.0.beta8 vs spec/couchrest/persistence_spec.rb in couchrest_model-1.0.0
- old
+ new
@@ -23,11 +23,11 @@
doc = Article.create_from_database({'_id' => 'testitem1', '_rev' => 123, 'name' => 'my test'})
doc.class.should eql(Article)
end
it "should instantialize document of different type" do
- doc = Article.create_from_database({'_id' => 'testitem2', '_rev' => 123, 'couchrest-type' => 'WithTemplateAndUniqueID', 'name' => 'my test'})
+ doc = Article.create_from_database({'_id' => 'testitem2', '_rev' => 123, Article.model_type_key => 'WithTemplateAndUniqueID', 'name' => 'my test'})
doc.class.should eql(WithTemplateAndUniqueID)
end
end
@@ -112,11 +112,11 @@
it "should set the id" do
@sobj.id.should be_an_instance_of(String)
end
it "should set the type" do
- @sobj['couchrest-type'].should == 'Basic'
+ @sobj[@sobj.model_type_key].should == 'Basic'
end
it "should accept true or false on save for validation" do
@sobj.should_receive(:valid?)
@sobj.save(true)
@@ -280,14 +280,20 @@
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 return nil if a blank id is requested" do
+ Article.get("").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
+ expect{ Article.get!('matt aimonetti') }.to raise_error
end
+ it "should raise an error if `get!` is requested with a blank id" do
+ expect{ Article.get!("") }.to 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
+ expect{ Article.find!('matt aimonetti') }.to raise_error
end
end
describe "getting a model with a subobjects array" do
before(:all) do