spec/riak/http_backend_spec.rb in riak-client-0.9.0.beta vs spec/riak/http_backend_spec.rb in riak-client-0.9.0.beta2
- old
+ new
@@ -74,11 +74,11 @@
@backend.should_not_receive(:load_object)
@backend.reload_object(@object)
end
it "should raise an exception when the response code is not 200 or 304" do
- @backend.should_receive(:get).and_raise(Riak::FailedRequest.new(:get, 200, 500, {}, ''))
+ @backend.should_receive(:get).and_raise(Riak::HTTPFailedRequest.new(:get, 200, 500, {}, ''))
lambda { @backend.reload_object(@object) }.should raise_error(Riak::FailedRequest)
end
it "should escape the bucket and key names" do
# @bucket.should_receive(:name).and_return("some/deep/path")
@@ -224,9 +224,21 @@
it "should return the full response hash for non-JSON responses" do
response = {:code => 200, :headers => {'content-type' => ["text/plain"]}, :body => 'This is some text.'}
@backend.stub!(:post).and_return(response)
@backend.mapred(@mr).should == response
+ end
+
+ it "should stream results through the block" do
+ data = File.read("spec/fixtures/multipart-mapreduce.txt")
+ @backend.should_receive(:post).with(200, "/mapred", {:chunked => true}, @mr.to_json, hash_including("Content-Type" => "application/json")).and_yield(data)
+ block = mock
+ block.should_receive(:ping).twice.and_return(true)
+ @backend.mapred(@mr) do |phase, data|
+ block.ping
+ phase.should == 0
+ data.should have(1).item
+ end
end
end
context "getting statistics" do
it "should get the status URL and parse the response as JSON" do