Solve the information leak problem between deprecations. Unfortunately this was caused by a nasty ruby bug.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668930 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/deprecation_spec.rb b/lib/rb/spec/deprecation_spec.rb
index 6c83ccd..6c3bdc9 100644
--- a/lib/rb/spec/deprecation_spec.rb
+++ b/lib/rb/spec/deprecation_spec.rb
@@ -176,8 +176,8 @@
describe "deprecate_class!" do
it_should_behave_like "deprecation"
- def stub_stderr(callstr, offset=1)
- STDERR.should_receive(:puts).with("Warning: class #{callstr} is deprecated")
+ def stub_stderr(klass, offset=1)
+ STDERR.should_receive(:puts).with("Warning: class #{klass} is deprecated")
line = caller.first[/\d+$/].to_i + offset
STDERR.should_receive(:puts).with(" from #{__FILE__}:#{line}")
end
@@ -259,8 +259,8 @@
describe "deprecate_module!" do
it_should_behave_like "deprecation"
- def stub_stderr(callstr, offset=1)
- STDERR.should_receive(:puts).with("Warning: module #{callstr} is deprecated")
+ def stub_stderr(mod, offset=1)
+ STDERR.should_receive(:puts).with("Warning: module #{mod} is deprecated")
line = caller.first[/\d+$/].to_i + offset
STDERR.should_receive(:puts).with(" from #{__FILE__}:#{line}")
end
@@ -344,4 +344,27 @@
klass.new.foo.should == "foo"
end
end
+
+ it "should not bleed info between deprecations" do
+ ensure_const_removed :DeprecationSpecOldModule do
+ ensure_const_removed :DeprecationSpecOldModule2 do
+ mod = Module.new do
+ def self.foo
+ "foo"
+ end
+ end
+ deprecate_module! :DeprecationSpecOldModule => mod
+ mod2 = Module.new do
+ def self.bar
+ "bar"
+ end
+ end
+ deprecate_module! :DeprecationSpecOldModule2 => mod2
+ stub_stderr(:DeprecationSpecOldModule)
+ ::DeprecationSpecOldModule.foo.should == "foo"
+ stub_stderr(:DeprecationSpecOldModule2)
+ ::DeprecationSpecOldModule2.bar.should == "bar"
+ end
+ end
+ end
end