Changeset 5114
- Timestamp:
- 09/15/06 03:56:25 (2 years ago)
- Files:
-
- trunk/activesupport/lib/active_support/deprecation.rb (modified) (1 diff)
- trunk/activesupport/test/deprecation_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/lib/active_support/deprecation.rb
r5113 r5114 87 87 module Assertions 88 88 def assert_deprecated(match = nil, &block) 89 last = collect_deprecations(&block).last90 assert last, "Expected a deprecation warning within the block but received none"89 warnings = collect_deprecations(&block) 90 assert !warnings.empty?, "Expected a deprecation warning within the block but received none" 91 91 if match 92 92 match = Regexp.new(Regexp.escape(match)) unless match.is_a?(Regexp) 93 assert _match match, last, "Deprecation warning didn't match #{match}: #{last}"93 assert warnings.any? { |w| w =~ match }, "No deprecation warning matched #{match}: #{warnings.join(', ')}" 94 94 end 95 95 end trunk/activesupport/test/deprecation_test.rb
r4978 r5114 79 79 end 80 80 81 def test_assert_deprecated_matches_any_warning 82 assert_deprecated 'abc' do 83 ActiveSupport::Deprecation.warn 'abc' 84 ActiveSupport::Deprecation.warn 'def' 85 end 86 rescue Test::Unit::AssertionFailedError 87 flunk 'assert_deprecated should match any warning in block, not just the last one' 88 end 89 81 90 def test_silence 82 91 ActiveSupport::Deprecation.silence do