Merge branch 'THRIFT-103'


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@682458 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/binaryprotocol_spec_shared.rb b/lib/rb/spec/binaryprotocol_spec_shared.rb
index 9a4af6b..ced15b4 100644
--- a/lib/rb/spec/binaryprotocol_spec_shared.rb
+++ b/lib/rb/spec/binaryprotocol_spec_shared.rb
@@ -63,6 +63,11 @@
     @prot.write_bool(false)
   end
 
+  it "should treat a nil bool as false" do
+    @prot.should_receive(:write_byte).with(0)
+    @prot.write_bool(nil)
+  end
+
   it "should write a byte" do
     # byte is small enough, let's check -128..127
     (-128..127).each do |i|
@@ -81,6 +86,10 @@
     lambda { @prot.write_byte(2**65) }.should raise_error(RangeError)
   end
 
+  it "should error gracefully when trying to write a nil byte" do
+    lambda { @prot.write_byte(nil) }.should raise_error
+  end
+
   it "should write an i16" do
     # try a random scattering of values
     # include the signed i16 minimum/maximum
@@ -101,6 +110,10 @@
     # lambda { @prot.write_i16(2**65) }.should raise_error(RangeError)
   end
 
+  it "should error gracefully when trying to write a nil i16" do
+    lambda { @prot.write_i16(nil) }.should raise_error
+  end
+
   it "should write an i32" do
     # try a random scattering of values
     # include the signed i32 minimum/maximum
@@ -121,6 +134,10 @@
     # lambda { @prot.write_i32(2 ** 65 + 5) }.should raise_error(RangeError)
   end
 
+  it "should error gracefully when trying to write a nil i32" do
+    lambda { @prot.write_i32(nil) }.should raise_error
+  end
+
   it "should write an i64" do
     # try a random scattering of values
     # try the signed i64 minimum/maximum
@@ -142,6 +159,10 @@
     # lambda { @prot.write_i64(2 ** 65 + 5) }.should raise_error(RangeError)
   end
 
+  it "should error gracefully when trying to write a nil i64" do
+    lambda { @prot.write_i64(nil) }.should raise_error
+  end
+
   it "should write a double" do
     # try a random scattering of values, including min/max
     @trans.should_receive(:write).with([Float::MIN].pack('G')).ordered
@@ -157,6 +178,10 @@
     end
   end
 
+  it "should error gracefully when trying to write a nil double" do
+    lambda { @prot.write_double(nil) }.should raise_error
+  end
+
   it "should write a string" do
     str = "hello world"
     @prot.should_receive(:write_i32).with(str.length).ordered
@@ -164,6 +189,10 @@
     @prot.write_string(str)
   end
 
+  it "should error gracefully when trying to write a nil string" do
+    lambda { @prot.write_string(nil) }.should raise_error
+  end
+
   # message footer is a noop
 
   it "should read a field header" do