- set @revision too when creating a Document
[couchobject.git] / spec / integration / document_integration_spec.rb
blobc3cd9103d7748e671c4054c8dcafebcf72a2a833
1 require File.dirname(__FILE__) + '/../spec_helper.rb'
2 require File.dirname(__FILE__) + "/integration_helper"
4 describe "Document functionality" do
5   include IntegrationSpecHelper
6   
7   before(:each) do
8     delete_test_db
9     @db = create_and_open_test_db
10   end
11   
12   it "should create our document" do
13     doc = CouchObject::Document.new("foo" => [1,2])
14     resp = doc.save(@db)
15     resp.code.should == 201
16     @db.get(doc.id).code.should == 200
17   end
18   
19   it "should update a document" do
20     doc = CouchObject::Document.new("foo" => [1,2])
21     resp = doc.save(@db)
22     resp.code.should == 201
23     
24     doc = @db.get(doc.id).to_document
25     doc.foo = "bar"
26     doc.save(@db).parsed_body["ok"].should == true
27     
28     doc = @db.get(doc.id).to_document
29     doc.foo.should == "bar"
30   end
31   
32   it "should update itself properly" do
33     doc = CouchObject::Document.new("foo" => [1,2])
34     doc.save(@db)
35     @db.all_documents.size.should == 1
36     doc.foo = "bar"
37     doc.save(@db)
38     @db.all_documents.size.should == 1
39   end
40   
41 end