Author: kclark
Date: Tue Jun 17 18:00:12 2008
New Revision: 668923
URL: http://svn.apache.org/viewvc?rev=668923&view=rev
Log:
Add new spec for deprecate_class!
Modified:
incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
incubator/thrift/trunk/lib/rb/spec/deprecation_spec.rb
Modified: incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb?rev=668923&r1=668922&r2=668923&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb Tue Jun 17 18:00:12 2008
@@ -134,5 +134,5 @@
:element => field[:element] }
end
end
- deprecate_class! :ThriftStruct => Struct
+ deprecate_class! :ThriftStruct => Struct
end
Modified: incubator/thrift/trunk/lib/rb/spec/deprecation_spec.rb
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/deprecation_spec.rb?rev=668923&r1=668922&r2=668923&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/deprecation_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/deprecation_spec.rb Tue Jun 17 18:00:12
2008
@@ -176,8 +176,26 @@
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