aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-09-15 05:54:18 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-09-15 05:54:18 +0000
commitd0c000ab9e90be4896744cb6ec107dffa573f2dd (patch)
treed5cb7431dd4621864fe184a76dd19b5fce0c3047 /activesupport/lib
parent069b0eaf0bd42a2474028022b1e907dc97cc2e41 (diff)
downloadrails-d0c000ab9e90be4896744cb6ec107dffa573f2dd.tar.gz
rails-d0c000ab9e90be4896744cb6ec107dffa573f2dd.tar.bz2
rails-d0c000ab9e90be4896744cb6ec107dffa573f2dd.zip
assert_deprecated returns result of block
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5115 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/deprecation.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb
index e4e1d187a5..50aff7582d 100644
--- a/activesupport/lib/active_support/deprecation.rb
+++ b/activesupport/lib/active_support/deprecation.rb
@@ -86,17 +86,19 @@ module ActiveSupport
module Assertions
def assert_deprecated(match = nil, &block)
- warnings = collect_deprecations(&block)
+ result, warnings = collect_deprecations(&block)
assert !warnings.empty?, "Expected a deprecation warning within the block but received none"
if match
match = Regexp.new(Regexp.escape(match)) unless match.is_a?(Regexp)
assert warnings.any? { |w| w =~ match }, "No deprecation warning matched #{match}: #{warnings.join(', ')}"
end
+ result
end
def assert_not_deprecated(&block)
- deprecations = collect_deprecations(&block)
+ result, deprecations = collect_deprecations(&block)
assert deprecations.empty?, "Expected no deprecation warning within the block but received #{deprecations.size}: \n #{deprecations * "\n "}"
+ result
end
private
@@ -106,8 +108,8 @@ module ActiveSupport
ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack|
deprecations << message
end
- yield
- deprecations
+ result = yield
+ [result, deprecations]
ensure
ActiveSupport::Deprecation.behavior = old_behavior
end