Add a few accessors and specs to prepare for the upcoming NonblockingServer


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668995 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/transport_spec.rb b/lib/rb/spec/transport_spec.rb
index 941df28..5d5c92f 100644
--- a/lib/rb/spec/transport_spec.rb
+++ b/lib/rb/spec/transport_spec.rb
@@ -26,6 +26,10 @@
         Transport.method_defined?(sym).should be_true
       end
     end
+
+    it "should alias << to write" do
+      Transport.instance_method(:<<).should == Transport.instance_method(:write)
+    end
   end
 
   describe ServerTransport do
@@ -208,6 +212,13 @@
       @buffer = MemoryBuffer.new
     end
 
+    it "should accept a buffer on input and use it directly" do
+      s = "this is a test"
+      @buffer = MemoryBuffer.new(s)
+      @buffer.read(4).should == "this"
+      s.should == " is a test"
+    end
+
     it "should always remain open" do
       @buffer.should be_open
       @buffer.close
@@ -235,6 +246,15 @@
       @buffer.available.should == 0
     end
 
+    it "should copy the given string whne resetting the buffer" do
+      s = "this is a test"
+      @buffer.reset_buffer(s)
+      @buffer.available.should == 14
+      @buffer.read(10)
+      @buffer.available.should == 4
+      s.should == "this is a test"
+    end
+
     it "should return from read what was given in write" do
       @buffer.write "test data"
       @buffer.read(4).should == "test"