THRIFT-709. Print enum value names in Ruby

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@911500 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/ThriftSpec.thrift b/lib/rb/spec/ThriftSpec.thrift
index f5c8c09..84111c1 100644
--- a/lib/rb/spec/ThriftSpec.thrift
+++ b/lib/rb/spec/ThriftSpec.thrift
@@ -42,28 +42,15 @@
   1: string greeting = "hello world"
 }
 
-union My_union {
-  1: bool im_true,
-  2: byte a_bite,
-  3: i16 integer16,
-  4: i32 integer32,
-  5: i64 integer64,
-  6: double double_precision,
-  7: string some_characters,
-  8: i32 other_i32
-}
-
-struct Struct_with_union {
-  1: My_union fun_union
-  2: i32 integer32
-  3: string some_characters
-}
-
 enum SomeEnum {
   ONE
   TWO
 }
 
+struct StructWithSomeEnum {
+  1: SomeEnum some_enum;
+}
+
 union TestUnion {
   /**
    * A doc string
@@ -114,3 +101,26 @@
   oneway void shutdown()
   void sleep(1:double seconds)
 }
+
+union My_union {
+  1: bool im_true,
+  2: byte a_bite,
+  3: i16 integer16,
+  4: i32 integer32,
+  5: i64 integer64,
+  6: double double_precision,
+  7: string some_characters,
+  8: i32 other_i32
+  9: SomeEnum some_enum;
+  10: map<SomeEnum, list<SomeEnum>> my_map;
+}
+
+struct Struct_with_union {
+  1: My_union fun_union
+  2: i32 integer32
+  3: string some_characters
+}
+
+struct StructWithEnumMap {
+  1: map<SomeEnum, list<SomeEnum>> my_map;
+}
\ No newline at end of file
diff --git a/lib/rb/spec/struct_spec.rb b/lib/rb/spec/struct_spec.rb
index 237f982..045b963 100644
--- a/lib/rb/spec/struct_spec.rb
+++ b/lib/rb/spec/struct_spec.rb
@@ -62,6 +62,12 @@
       Foo.new(:simple => 52).should_not == Foo.new
     end
 
+    it "should print enum value names in inspect" do
+      StructWithSomeEnum.new(:some_enum => SomeEnum::ONE).inspect.should == "<SpecNamespace::StructWithSomeEnum some_enum:ONE (0)>"
+
+      StructWithEnumMap.new(:my_map => {SomeEnum::ONE => [SomeEnum::TWO]}).inspect.should == "<SpecNamespace::StructWithEnumMap my_map:{ONE (0): [TWO (1)]}>"
+    end
+
     it "should read itself off the wire" do
       struct = Foo.new
       prot = BaseProtocol.new(mock("transport"))
diff --git a/lib/rb/spec/union_spec.rb b/lib/rb/spec/union_spec.rb
index 07a3f94..f39d033 100644
--- a/lib/rb/spec/union_spec.rb
+++ b/lib/rb/spec/union_spec.rb
@@ -147,5 +147,11 @@
       union.get_set_field.should == :integer32
       union.get_value.should == 26
     end
+    
+    it "should print enum value name when inspected" do
+      My_union.new(:some_enum => SomeEnum::ONE).inspect.should == "<SpecNamespace::My_union some_enum: ONE (0)>"
+      
+      My_union.new(:my_map => {SomeEnum::ONE => [SomeEnum::TWO]}).inspect.should == "<SpecNamespace::My_union my_map: {ONE (0): [TWO (1)]}>" 
+    end
   end
 end