From: Kevin Clark Date: Thu, 26 Jun 2008 18:45:29 +0000 (+0000) Subject: rb: Ensure the specs that expect deprecation warnings actually get them [THRIFT-56] X-Git-Tag: 0.2.0~491 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=28744ab833688ffe95eb4634aae33ad6f57a9054;p=common%2Fthrift.git rb: Ensure the specs that expect deprecation warnings actually get them [THRIFT-56] Author: Kevin Ballard git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@671985 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/rb/lib/thrift/deprecation.rb b/lib/rb/lib/thrift/deprecation.rb index 6a422a8b..175f0ce5 100644 --- a/lib/rb/lib/thrift/deprecation.rb +++ b/lib/rb/lib/thrift/deprecation.rb @@ -123,6 +123,10 @@ module Thrift::DeprecationProxy # :nodoc: dir = File.dirname(__FILE__) stack.find { |frame| frame[0,dir.size] != dir } end + def self.reset_deprecation_warnings + CLASS_MAPPING.each { |k,v| v[2] = false } + MODULE_MAPPING.each { |k,v| v[2] = false } + end end module Kernel diff --git a/lib/rb/spec/backwards_compatibility_spec.rb b/lib/rb/spec/backwards_compatibility_spec.rb index eb35a95c..6c9d8355 100644 --- a/lib/rb/spec/backwards_compatibility_spec.rb +++ b/lib/rb/spec/backwards_compatibility_spec.rb @@ -5,6 +5,7 @@ require 'thrift/transport/httpclient' context "Backwards compatibility" do specify "old class names should map to new classes" do + Thrift::DeprecationProxy.reset_deprecation_warnings # use an Array because a Hash will call #hash and trigger deprecation warnings klasses = [ [:module, :ThriftClient, Thrift::Client], diff --git a/lib/rb/spec/deprecation_spec.rb b/lib/rb/spec/deprecation_spec.rb index 4ca4ee30..77786d81 100644 --- a/lib/rb/spec/deprecation_spec.rb +++ b/lib/rb/spec/deprecation_spec.rb @@ -14,6 +14,10 @@ shared_examples_for "deprecation" do Thrift.const_set :DEPRECATION, false end + before(:each) do + Thrift::DeprecationProxy.reset_deprecation_warnings + end + def ensure_const_removed(name, &block) begin block.call