hit a snag with rest-client and query params

This commit is contained in:
Chris Anderson 2008-03-19 15:21:27 -07:00
parent 420168be70
commit e7ea12f2ae
2 changed files with 20 additions and 0 deletions

View file

@ -32,6 +32,11 @@ class CouchRest
end end
end end
def delete doc
slug = CGI.escape(doc['_id'])
CouchRest.delete "#{@root}/#{slug}?rev=#{doc['_rev']}"
end
def delete! def delete!
CouchRest.delete @root CouchRest.delete @root
end end

View file

@ -69,6 +69,20 @@ describe CouchRest::Database do
end end
end end
describe "DELETE existing document" do
before(:each) do
@r = @db.save({'lemons' => 'from texas', 'and' => 'spain'})
@docid = "http://example.com/stuff.cgi?things=and%20stuff"
@db.save({'_id' => @docid, 'will-exist' => 'here'})
end
it "should work" do
doc = @db.get(@r['id'])
doc['and'].should == 'spain'
@db.delete doc
lambda{@db.get @r['id']}.should raise_error
end
end
it "should list documents" do it "should list documents" do
5.times do 5.times do
@db.save({'another' => 'doc', 'will-exist' => 'anywhere'}) @db.save({'another' => 'doc', 'will-exist' => 'anywhere'})
@ -98,4 +112,5 @@ describe CouchRest::Database do
end end
end end
end end