aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-08-08 06:57:59 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-08-08 06:57:59 +0000
commit0a44c858660600960a2f7be75ce53e9a7841ae76 (patch)
tree5a03e5cc6a5aa9d101bc20a9e051d8e6edb06e56 /activesupport
parent52c9ad4c9828504ff7859a9dc7ee33d3bdd532c4 (diff)
downloadrails-0a44c858660600960a2f7be75ce53e9a7841ae76.tar.gz
rails-0a44c858660600960a2f7be75ce53e9a7841ae76.tar.bz2
rails-0a44c858660600960a2f7be75ce53e9a7841ae76.zip
Include called method in instance variable deprecation warning.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4719 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/deprecation.rb8
-rw-r--r--activesupport/test/deprecation_test.rb5
2 files changed, 4 insertions, 9 deletions
diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb
index d7acdc2bd8..f81a2a02e5 100644
--- a/activesupport/lib/active_support/deprecation.rb
+++ b/activesupport/lib/active_support/deprecation.rb
@@ -51,7 +51,7 @@ module ActiveSupport
def assert_deprecated(match = nil, &block)
last = with_last_message_tracking_deprecation_behavior(&block)
assert last, "Expected a deprecation warning within the block but received none"
- match = Regexp.new(match) unless match.is_a?(Regexp)
+ match = Regexp.new(Regexp.escape(match)) unless match.is_a?(Regexp)
assert_match match, last, "Deprecation warning didn't match #{match}: #{last}"
end
@@ -81,12 +81,8 @@ module ActiveSupport
end
private
- def deprecation_warning(called, callstack)
- ActiveSupport::Deprecation.warn("Using #{@var} directly is deprecated - call #{@method} instead.", callstack)
- end
-
def method_missing(called, *args, &block)
- deprecation_warning called, caller
+ ActiveSupport::Deprecation.warn("#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}. Args: #{args.inspect}", caller)
@instance.__send__(@method).__send__(called, *args, &block)
end
end
diff --git a/activesupport/test/deprecation_test.rb b/activesupport/test/deprecation_test.rb
index 319bd231d7..472fdecaaf 100644
--- a/activesupport/test/deprecation_test.rb
+++ b/activesupport/test/deprecation_test.rb
@@ -68,8 +68,7 @@ class DeprecationTest < Test::Unit::TestCase
def test_deprecated_instance_variable_proxy
assert_not_deprecated { @dtc.request.size }
- warning = 'Using @request directly is deprecated - call request instead.'
- assert_deprecated(warning) { assert_equal @dtc.request.size, @dtc.old_request.size }
- assert_deprecated(warning) { assert_equal @dtc.request.to_s, @dtc.old_request.to_s }
+ assert_deprecated('@request.size') { assert_equal @dtc.request.size, @dtc.old_request.size }
+ assert_deprecated('@request.to_s') { assert_equal @dtc.request.to_s, @dtc.old_request.to_s }
end
end