Add two missing tests for FramedTransport
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668981 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/transport_spec.rb b/lib/rb/spec/transport_spec.rb
index 5c9da72..941df28 100644
--- a/lib/rb/spec/transport_spec.rb
+++ b/lib/rb/spec/transport_spec.rb
@@ -137,6 +137,10 @@
ftrans.read(16).should == "a frame"
end
+ it "should return nothing if asked for <= 0" do
+ FramedTransport.new(@trans).read(-2).should == ""
+ end
+
it "should pull a new frame when the first is exhausted" do
frame = "this is a frame"
frame2 = "yet another frame"
@@ -159,6 +163,15 @@
ftrans.write("this is a frame")
end
+ it "should write slices of the buffer" do
+ ftrans = FramedTransport.new(@trans)
+ ftrans.write("foobar", 3)
+ ftrans.write("barfoo", 1)
+ @trans.stub!(:flush)
+ @trans.should_receive(:write).with("\000\000\000\004foob")
+ ftrans.flush
+ end
+
it "should flush frames with a 4-byte header" do
ftrans = FramedTransport.new(@trans)
@trans.should_receive(:write).with("\000\000\000\035one/two/three/this is a frame").ordered