start key and such on all-docs

This commit is contained in:
Chris Anderson 2008-05-24 17:01:28 -07:00
parent b93f6e7677
commit c776b80ac6
2 changed files with 17 additions and 8 deletions

View file

@ -9,8 +9,9 @@ class CouchRest
@root = "#{host}/#{name}" @root = "#{host}/#{name}"
end end
def documents def documents params = nil
CouchRest.get "#{@root}/_all_docs" url = CouchRest.paramify_url "#{@root}/_all_docs", params
CouchRest.get url
end end
def temp_view funcs, params = nil def temp_view funcs, params = nil

View file

@ -237,12 +237,20 @@ describe CouchRest::Database do
ds['rows'].should be_an_instance_of(Array) ds['rows'].should be_an_instance_of(Array)
ds['rows'][0]['id'].should_not be_nil ds['rows'][0]['id'].should_not be_nil
ds['total_rows'].should == 5 ds['total_rows'].should == 5
# should I use a View class? end
# ds.should be_an_instance_of(CouchRest::View)
# ds.rows = [] it "should list documents with keys and such" do
# ds.rows.include?(...) 9.times do |i|
# ds.total_rows @db.save({'_id' => "doc#{i}",'another' => 'doc', 'will-exist' => 'here'})
end
ds = @db.documents
ds['rows'].should be_an_instance_of(Array)
ds['rows'][0]['id'].should == "doc0"
ds['total_rows'].should == 9
ds = @db.documents(:startkey => 'doc0', :endkey => 'doc3')
ds['rows'].length.should == 4
ds = @db.documents(:key => 'doc0')
ds['rows'].length.should == 1
end end
describe "deleting a database" do describe "deleting a database" do