| |   |
| 149 | 149 | db = CouchObject::Database.new(@uri, "foo") |
| 150 | 150 | doc = CouchObject::Document.new({"foo" => "bar"}) |
| 151 | 151 | |
| 152 | | FakeRespons = Struct.new(:to_document) |
| 152 | FakeResponse = Struct.new(:to_document) |
| 153 | 153 | FakeDocument = Struct.new(:id, :revision) |
| 154 | 154 | document = \ |
| 155 | 155 | FakeDocument.new("2113826070","id"=>"594F126A80B45C8AC2298E0393E20192") |
| 156 | | response = FakeRespons.new(document) |
| 156 | response = FakeResponse.new(document) |
| 157 | 157 | |
| 158 | 158 | db.should_receive(:post).with("", JSON.unparse("foo" => "bar")). |
| 159 | 159 | and_return(response) |
| 160 | 160 | db.store(doc) |
| 161 | 161 | end |
| 162 | 162 | |
| 163 | it "should bulk load an array of documents" do |
| 164 | db = CouchObject::Database.new(@uri, "foo") |
| 165 | resp = Struct.new(:body).new |
| 166 | resp.body = { "ok" => "true", "results" => [{"ok" => "true", "_id" => "1"}, {"ok" => "true", "_id" => "1"}] }.to_json |
| 167 | db.should_receive(:post).with("_bulk_docs", JSON.unparse({ |
| 168 | "docs" => [{"foo" => "bar"}, {"foo" => "baz"}] |
| 169 | })).and_return(resp) |
| 170 | res = db.bulk_load([CouchObject::Document.new({"foo" => "bar"}), CouchObject::Document.new({"foo" => "baz"})]) |
| 171 | end |
| 172 | |
| 163 | 173 | #it "should url encode paths" |
| 164 | 174 | end |
| toggle raw diff |
--- a/spec/database_spec.rb
+++ b/spec/database_spec.rb
@@ -149,16 +149,26 @@ describe CouchObject::Database do
db = CouchObject::Database.new(@uri, "foo")
doc = CouchObject::Document.new({"foo" => "bar"})
- FakeRespons = Struct.new(:to_document)
+ FakeResponse = Struct.new(:to_document)
FakeDocument = Struct.new(:id, :revision)
document = \
FakeDocument.new("2113826070","id"=>"594F126A80B45C8AC2298E0393E20192")
- response = FakeRespons.new(document)
+ response = FakeResponse.new(document)
db.should_receive(:post).with("", JSON.unparse("foo" => "bar")).
and_return(response)
db.store(doc)
end
+ it "should bulk load an array of documents" do
+ db = CouchObject::Database.new(@uri, "foo")
+ resp = Struct.new(:body).new
+ resp.body = { "ok" => "true", "results" => [{"ok" => "true", "_id" => "1"}, {"ok" => "true", "_id" => "1"}] }.to_json
+ db.should_receive(:post).with("_bulk_docs", JSON.unparse({
+ "docs" => [{"foo" => "bar"}, {"foo" => "baz"}]
+ })).and_return(resp)
+ res = db.bulk_load([CouchObject::Document.new({"foo" => "bar"}), CouchObject::Document.new({"foo" => "baz"})])
+ end
+
#it "should url encode paths"
end
\ No newline at end of file |