From: Kevin Clark Date: Wed, 18 Jun 2008 01:00:12 +0000 (+0000) Subject: Add new spec for deprecate_class! X-Git-Tag: 0.2.0~626 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=f5754acff9db00b949b68b4208dc980d511acf7a;p=common%2Fthrift.git Add new spec for deprecate_class! git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668923 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/rb/lib/thrift/struct.rb b/lib/rb/lib/thrift/struct.rb index 393060e9..583d3da9 100644 --- a/lib/rb/lib/thrift/struct.rb +++ b/lib/rb/lib/thrift/struct.rb @@ -134,5 +134,5 @@ module Thrift :element => field[:element] } end end - deprecate_class! :ThriftStruct => Struct + deprecate_class! :ThriftStruct => Struct end diff --git a/lib/rb/spec/deprecation_spec.rb b/lib/rb/spec/deprecation_spec.rb index bec299c6..cb462b45 100644 --- a/lib/rb/spec/deprecation_spec.rb +++ b/lib/rb/spec/deprecation_spec.rb @@ -176,8 +176,26 @@ describe "deprecate_class!" do end end deprecate_class! :DeprecationSpecOldClass => klass - DeprecationSpecOldClass.should eql(klass) - DeprecationSpecOldClass.new.foo.should == "foo" + ::DeprecationSpecOldClass.should eql(klass) + ::DeprecationSpecOldClass.new.foo.should == "foo" + ensure + Object.send :remove_const, :DeprecationSpecOldClass if Object.const_defined? :DeprecationSpecOldClass + end + end + + it "should create a global constant even from inside a module" do + begin + klass = nil #define scoping + mod = Module.new do + klass = Class.new do + def foo + "foo" + end + end + deprecate_class! :DeprecationSpecOldClass => klass + end + ::DeprecationSpecOldClass.should eql(klass) + ::DeprecationSpecOldClass.new.foo.should == "foo" ensure Object.send :remove_const, :DeprecationSpecOldClass if Object.const_defined? :DeprecationSpecOldClass end