You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by kc...@apache.org on 2008/06/18 03:06:43 UTC
svn commit: r668948 - /incubator/thrift/trunk/lib/rb/spec/protocol_spec.rb
Author: kclark
Date: Tue Jun 17 18:06:42 2008
New Revision: 668948
URL: http://svn.apache.org/viewvc?rev=668948&view=rev
Log:
Finish speccing out Protocol and ProtocolFactory
Modified:
incubator/thrift/trunk/lib/rb/spec/protocol_spec.rb
Modified: incubator/thrift/trunk/lib/rb/spec/protocol_spec.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/protocol_spec.rb?rev=668948&r1=668947&r2=668948&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/protocol_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/protocol_spec.rb Tue Jun 17 18:06:42 2008
@@ -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