rb: The deprecation stuff should skip thrift library code when showing caller [THRIFT-56]
Author: Kevin Ballard <kevin@rapleaf.com>
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@671984 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/deprecation_spec.rb b/lib/rb/spec/deprecation_spec.rb
index b0cc527..4ca4ee3 100644
--- a/lib/rb/spec/deprecation_spec.rb
+++ b/lib/rb/spec/deprecation_spec.rb
@@ -311,12 +311,14 @@
def stub_stderr(mod, offset=1, called=nil)
STDERR.should_receive(:puts).with("Warning: module #{mod} is deprecated")
+ source = Regexp.escape(__FILE__) + ":"
if offset
line = (called || caller.first)[/\d+$/].to_i + offset
- STDERR.should_receive(:puts).with(" from #{__FILE__}:#{line}")
+ source += Regexp.escape(line.to_s)
else
- STDERR.should_receive(:puts).with(/^ from #{Regexp.escape(__FILE__)}:/)
+ source += "\d+"
end
+ STDERR.should_receive(:puts).with(/^ from #{source}(?::in `[^']+')?$/)
end
it "should create a new global constant that points to the old one" do
@@ -423,4 +425,15 @@
end
end
end
+
+ it "should skip thrift library code when printing caller" do
+ klass = Class.new do
+ include ThriftStruct
+ FIELDS = {
+ 1 => {:name => "foo", :type => Thrift::Types::STRING}
+ }
+ end
+ stub_stderr('ThriftStruct')
+ klass.new(:foo => "foo")
+ end
end