spec/integration/riak/http_backends_spec.rb in riak-client-0.9.4 vs spec/integration/riak/http_backends_spec.rb in riak-client-0.9.5
- old
+ new
@@ -40,6 +40,32 @@
it_should_behave_like "Unified backend API"
end
end
end
+
+ class Reader < Array
+ def read(*args)
+ shift
+ end
+
+ def size
+ join.size
+ end
+ end
+
+ class SizelessReader < Reader
+ undef :size
+ end
+
+ describe 'NetHTTPBackend' do
+ subject { Riak::Client::NetHTTPBackend.new(@client) }
+ let(:file) { File.open(__FILE__) }
+ let(:sized) { Reader.new(["foo", "bar", "baz"]) }
+ let(:sizeless) { SizelessReader.new(["foo", "bar", "baz"]) }
+ it "should set the content-length or transfer-encoding properly on IO uploads" do
+ lambda { subject.put(204, "/riak/nethttp", "test-file", file, {"Content-Type" => "text/plain"}) }.should_not raise_error
+ lambda { subject.put(204, "/riak/nethttp", "test-sized", sized, {"Content-Type" => "text/plain"}) }.should_not raise_error
+ lambda { subject.put(204, "/riak/nethttp", "test-file", sizeless, {"Content-Type" => "text/plain"}) }.should_not raise_error
+ end
+ end
end