Streamer fixes

* url must be quoted inside the curl command otherwise '&' between
  params are interpreted by shells
* View url format updated
* Streamer yielded the last row returned by curl ("}]") as nil
* Specs
This commit is contained in:
Julien Sanchez 2009-10-08 18:27:22 +08:00 committed by Matt Aimonetti
parent d8e7652680
commit 1c43a8f3d3
3 changed files with 51 additions and 8 deletions

View file

@ -9,6 +9,14 @@ describe CouchRest::Streamer do
@streamer = CouchRest::Streamer.new(@db)
@docs = (1..1000).collect{|i| {:integer => i, :string => i.to_s}}
@db.bulk_save(@docs)
@db.save_doc({
"_id" => "_design/first",
:views => {
:test => {
:map => "function(doc){for(var w in doc){ if(!w.match(/^_/))emit(w,doc[w])}}"
}
}
})
end
it "should yield each row in a view" do
@ -19,5 +27,26 @@ describe CouchRest::Streamer do
end
count.should == 1001
end
end
it "should accept several params" do
count = 0
@streamer.view("_design/first/_view/test", :include_docs => true, :limit => 5) do |row|
count += 1
end
count.should == 5
end
it "should accept both view formats" do
count = 0
@streamer.view("_design/first/_view/test") do |row|
count += 1
end
count.should == 2000
count = 0
@streamer.view("first/test") do |row|
count += 1
end
count.should == 2000
end
end