THRIFT-708. rb: Is set checking methods
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@911557 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/ThriftSpec.thrift b/lib/rb/spec/ThriftSpec.thrift
index 84111c1..b497a60 100644
--- a/lib/rb/spec/ThriftSpec.thrift
+++ b/lib/rb/spec/ThriftSpec.thrift
@@ -69,6 +69,7 @@
5: map<i32, map<string, double>> complex,
6: set<i16> shorts = [5, 17, 239],
7: optional string opt_string
+ 8: bool my_bool
}
struct BoolStruct {
diff --git a/lib/rb/spec/struct_spec.rb b/lib/rb/spec/struct_spec.rb
index 045b963..4b46284 100644
--- a/lib/rb/spec/struct_spec.rb
+++ b/lib/rb/spec/struct_spec.rb
@@ -68,6 +68,13 @@
StructWithEnumMap.new(:my_map => {SomeEnum::ONE => [SomeEnum::TWO]}).inspect.should == "<SpecNamespace::StructWithEnumMap my_map:{ONE (0): [TWO (1)]}>"
end
+ it "should offer field? methods" do
+ Foo.new.opt_string?.should be_false
+ Foo.new(:simple => 52).simple?.should be_true
+ Foo.new(:my_bool => false).my_bool?.should be_true
+ Foo.new(:my_bool => true).my_bool?.should be_true
+ 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 f39d033..f563b0b 100644
--- a/lib/rb/spec/union_spec.rb
+++ b/lib/rb/spec/union_spec.rb
@@ -153,5 +153,12 @@
My_union.new(:my_map => {SomeEnum::ONE => [SomeEnum::TWO]}).inspect.should == "<SpecNamespace::My_union my_map: {ONE (0): [TWO (1)]}>"
end
+
+ it "should offer field? methods" do
+ My_union.new.some_enum?.should be_false
+ My_union.new(:some_enum => SomeEnum::ONE).some_enum?.should be_true
+ My_union.new(:im_true => false).im_true?.should be_true
+ My_union.new(:im_true => true).im_true?.should be_true
+ end
end
end