Finalizing support for including hash codes in Design documents

This commit is contained in:
Sam Lown 2011-04-14 00:19:10 +02:00
parent 706880fceb
commit 00a4cc7f3b
7 changed files with 25 additions and 94 deletions

View file

@ -535,6 +535,7 @@ describe "Design View" do
# disable real execution!
@design_doc = mock("DesignDoc")
@design_doc.stub!(:view_on)
@obj.model.stub!(:save_design_doc)
@obj.model.stub!(:design_doc).and_return(@design_doc)
end
@ -557,6 +558,12 @@ describe "Design View" do
@obj.send(:execute)
end
it "should call to save the design document" do
@obj.should_receive(:can_reduce?).and_return(false)
@obj.model.should_receive(:save_design_doc).with(DB)
@obj.send(:execute)
end
it "should populate the results" do
@obj.should_receive(:can_reduce?).and_return(true)
@design_doc.should_receive(:view_on).and_return('foos')
@ -564,22 +571,6 @@ describe "Design View" do
@obj.result.should eql('foos')
end
it "should retry once on a resource not found error" do
@obj.should_receive(:can_reduce?).and_return(true)
@obj.model.should_receive(:save_design_doc)
@design_doc.should_receive(:view_on).ordered.and_raise(RestClient::ResourceNotFound)
@design_doc.should_receive(:view_on).ordered.and_return('foos')
@obj.send(:execute)
@obj.result.should eql('foos')
end
it "should retry twice and fail on a resource not found error" do
@obj.should_receive(:can_reduce?).and_return(true)
@obj.model.should_receive(:save_design_doc)
@design_doc.should_receive(:view_on).twice.and_raise(RestClient::ResourceNotFound)
lambda { @obj.send(:execute) }.should raise_error(RestClient::ResourceNotFound)
end
it "should remove nil values from query" do
@obj.should_receive(:can_reduce?).and_return(true)
@obj.stub!(:use_database).and_return('database')

View file

@ -32,7 +32,7 @@ RSpec.configure do |config|
cr = TEST_SERVER
test_dbs = cr.databases.select { |db| db =~ /^#{TESTDB}/ }
test_dbs.each do |db|
# cr.database(db).delete! rescue nil
cr.database(db).delete! rescue nil
end
end
end