spec the error doc
This commit is contained in:
parent
f655284d8b
commit
1eac462612
2 changed files with 17 additions and 1 deletions
1
README
1
README
|
@ -14,6 +14,7 @@ response = @db.save({:key => 'value', 'another key' => 'another value'})
|
|||
doc = @db.get(response['id'])
|
||||
puts doc.inspect
|
||||
|
||||
Please note that @cr.database('a-db-name') does not go over the wire at all. So it won't raise an error if the database does not exist. If you need to ensure that a database exists, call: @cr.create_db(dbname) rescue nilkey
|
||||
|
||||
Bulk Save:
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ describe CouchRest::Database do
|
|||
@db.get(r['id'])
|
||||
end
|
||||
end
|
||||
|
||||
it "should add them with uniq ids" do
|
||||
rs = @db.bulk_save([
|
||||
{"_id" => "oneB", "wild" => "and random"},
|
||||
|
@ -147,6 +148,7 @@ describe CouchRest::Database do
|
|||
@db.get(r['id'])
|
||||
end
|
||||
end
|
||||
|
||||
it "in the case of an id conflict should not insert anything" do
|
||||
@r = @db.save({'lemons' => 'from texas', 'and' => 'how', "_id" => "oneB"})
|
||||
|
||||
|
@ -159,9 +161,22 @@ describe CouchRest::Database do
|
|||
end.should raise_error(RestClient::RequestFailed)
|
||||
|
||||
lambda do
|
||||
@db.get('twoB')
|
||||
@db.get('twoB')
|
||||
end.should raise_error(RestClient::ResourceNotFound)
|
||||
end
|
||||
it "should raise an error that is useful for recovery" do
|
||||
@r = @db.save({"_id" => "taken", "field" => "stuff"})
|
||||
begin
|
||||
rs = @db.bulk_save([
|
||||
{"_id" => "taken", "wild" => "and random"},
|
||||
{"_id" => "free", "mild" => "yet local"},
|
||||
{"another" => ["set","of","keys"]}
|
||||
])
|
||||
rescue RestClient::RequestFailed => e
|
||||
# soon CouchDB will provide _which_ docs conflicted
|
||||
JSON.parse(e.response.body)['error'].should == 'conflict'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST (new document without an id)" do
|
||||
|
|
Loading…
Reference in a new issue