PUT to update

This commit is contained in:
Chris Anderson 2008-03-19 16:01:04 -07:00
parent e7ea12f2ae
commit 43f51c5490
2 changed files with 23 additions and 1 deletions

View file

@ -57,7 +57,8 @@ module RestClient
def execute_inner
uri = parse_url(url)
transmit uri, net_http_class(method).new(uri.path, make_headers(headers)), payload
uri_path = uri.respond_to?(:request_uri) ? uri.request_uri : uri.path
transmit uri, net_http_class(method).new(uri_path, make_headers(headers)), payload
end
def make_headers(user_headers)

View file

@ -69,6 +69,22 @@ describe CouchRest::Database do
end
end
describe "PUT (existing document with rev)" do
before(:each) do
@db.save({'_id' => 'my-doc', 'will-exist' => 'here'})
@doc = @db.get('my-doc')
end
it "should start with the document" do
@doc['will-exist'].should == 'here'
end
it "should update the document" do
@doc['them-keys'] = 'huge'
@db.save(@doc)
now = @db.get('my-doc')
now['them-keys'].should == 'huge'
end
end
describe "DELETE existing document" do
before(:each) do
@r = @db.save({'lemons' => 'from texas', 'and' => 'spain'})
@ -81,6 +97,11 @@ describe CouchRest::Database do
@db.delete doc
lambda{@db.get @r['id']}.should raise_error
end
it "should work with uri id" do
doc = @db.get(@docid)
@db.delete doc
lambda{@db.get @docid}.should raise_error
end
end
it "should list documents" do