rb: Bugfix for deprecation code [kevin@rapleaf.com][THRIFT-50]
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@670976 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/deprecation_spec.rb b/lib/rb/spec/deprecation_spec.rb
index 629629b..57c2f77 100644
--- a/lib/rb/spec/deprecation_spec.rb
+++ b/lib/rb/spec/deprecation_spec.rb
@@ -269,6 +269,31 @@
end
end
end
+
+ it "should work when Object.inherited calls a method on self" do
+ ensure_const_removed :DeprecationSpecOldClass do
+ old_inherited = Object.method(:inherited)
+ begin
+ (class << Object;self;end).class_eval do
+ define_method :inherited do |cls|
+ cls.inspect
+ old_inherited.call(cls)
+ end
+ end
+ klass = Class.new do
+ def foo
+ "foo"
+ end
+ end
+ STDERR.should_receive(:puts).exactly(0).times
+ lambda { deprecate_class! :DeprecationSpecOldClass => klass }.should_not raise_error
+ ensure
+ (class << Object;self;end).class_eval do
+ define_method :inherited, old_inherited
+ end
+ end
+ end
+ end
end
describe "deprecate_module!" do