THRIFT-553. rb: thrift structs should be comparable (<=>)
This patch adds the spaceship operator to the struct and union base classes, enabling object comparisons between objects without regenerating code.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@911644 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/struct_spec.rb b/lib/rb/spec/struct_spec.rb
index c1271b9..c937023 100644
--- a/lib/rb/spec/struct_spec.rb
+++ b/lib/rb/spec/struct_spec.rb
@@ -79,6 +79,16 @@
       Foo.new(:my_bool => true).my_bool?.should be_true
     end
 
+    it "should be comparable" do
+      s1 = StructWithSomeEnum.new(:some_enum => SomeEnum::ONE)
+      s2 = StructWithSomeEnum.new(:some_enum => SomeEnum::TWO)
+
+      (s1 <=> s2).should == -1
+      (s2 <=> s1).should == 1
+      (s1 <=> s1).should == 0
+      (s1 <=> StructWithSomeEnum.new()).should == -1
+    end
+
     it "should read itself off the wire" do
       struct = Foo.new
       prot = BaseProtocol.new(mock("transport"))