Finish speccing out Protocol and ProtocolFactory


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668948 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/protocol_spec.rb b/lib/rb/spec/protocol_spec.rb
index f2b5080..6c08c43 100644
--- a/lib/rb/spec/protocol_spec.rb
+++ b/lib/rb/spec/protocol_spec.rb
@@ -4,11 +4,17 @@
   include Thrift
 
   before(:each) do
-    @prot = Protocol.new(mock("MockTransport"))
+    @trans = mock("MockTransport")
+    @prot = Protocol.new(@trans)
   end
 
   describe Protocol do
     # most of the methods are stubs, so we can ignore them
+
+    it "should make trans accessible" do
+      @prot.trans.should eql(@trans)
+    end
+
     it "should write out a field nicely" do
       @prot.should_receive(:write_field_begin).with('field', 'type', 'fid').ordered
       @prot.should_receive(:write_type).with('type', 'value').ordered
@@ -94,5 +100,36 @@
       @prot.should_receive(:read_struct_end).ordered
       real_skip.call(Types::STRUCT)
     end
+
+    it "should skip maps" do
+      real_skip = @prot.method(:skip)
+      @prot.should_receive(:read_map_begin).ordered.and_return([Types::STRING, Types::STRUCT, 7])
+      @prot.should_receive(:skip).ordered.exactly(14).times # once per key and once per value
+      @prot.should_receive(:read_map_end).ordered
+      real_skip.call(Types::MAP)
+    end
+
+    it "should skip sets" do
+      real_skip = @prot.method(:skip)
+      @prot.should_receive(:read_set_begin).ordered.and_return([Types::I64, 9])
+      @prot.should_receive(:skip).with(Types::I64).ordered.exactly(9).times
+      @prot.should_receive(:read_set_end)
+      real_skip.call(Types::SET)
+    end
+
+    it "should skip lists" do
+      real_skip = @prot.method(:skip)
+      @prot.should_receive(:read_list_begin).ordered.and_return([Types::DOUBLE, 11])
+      @prot.should_receive(:skip).with(Types::DOUBLE).ordered.exactly(11).times
+      @prot.should_receive(:read_list_end)
+      real_skip.call(Types::LIST)
+    end
+  end
+
+  describe ProtocolFactory do
+    it "should return nil" do
+      # returning nil since Protocol is just an abstract class
+      ProtocolFactory.new.get_protocol(mock("MockTransport")).should be_nil
+    end
   end
 end