From ff47ba9adb39976723752abfd6fbb72d7a55eaf1 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 2 Jan 2008 09:08:14 +0000 Subject: Ruby 1.9 compat: add #raise to AS::BasicObject, fixup Duration argument error. Closes #10594. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8523 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/CHANGELOG | 2 +- activesupport/lib/active_support/basic_object.rb | 5 +++++ activesupport/lib/active_support/duration.rb | 2 +- activesupport/test/core_ext/duration_test.rb | 11 +++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index ad3b76aa48..f708302c7e 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -6,7 +6,7 @@ * Hash#symbolize_keys skips keys that can't be symbolized. #10500 [Brad Greenlee] -* Ruby 1.9 compatibility. #1689, #10466, #10468, #10554, #10632 [Cheah Chu Yeow, Pratik Naik, Jeremy Kemper, Dirkjan Bussink] +* Ruby 1.9 compatibility. #1689, #10466, #10468, #10554, #10594, #10632 [Cheah Chu Yeow, Pratik Naik, Jeremy Kemper, Dirkjan Bussink, fxn] * TimeZone#to_s uses UTC rather than GMT. #1689 [Cheah Chu Yeow] diff --git a/activesupport/lib/active_support/basic_object.rb b/activesupport/lib/active_support/basic_object.rb index 009a521a40..bb01a47508 100644 --- a/activesupport/lib/active_support/basic_object.rb +++ b/activesupport/lib/active_support/basic_object.rb @@ -6,6 +6,11 @@ module ActiveSupport class BasicObject < ::BasicObject undef_method :== undef_method :equal? + + # Let ActiveSupport::BasicObject at least raise exceptions. + def raise(*args) + ::Object.send(:raise, *args) + end end else require 'blankslate' diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb index 82b38e79b5..ff51b49dcf 100644 --- a/activesupport/lib/active_support/duration.rb +++ b/activesupport/lib/active_support/duration.rb @@ -82,7 +82,7 @@ module ActiveSupport t.advance(type => sign * number) end else - raise ArgumentError, "expected a time or date, got #{time.inspect}" + raise ::ArgumentError, "expected a time or date, got #{time.inspect}" end end end diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index 125232bd40..2a86a7b1e7 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -18,4 +18,15 @@ class DurationTest < Test::Unit::TestCase def test_plus_with_time assert_equal 1 + 1.second, 1.second + 1, "Duration + Numeric should == Numeric + Duration" end + + def test_argument_error + begin + 1.second.ago('') + flunk("no exception was raised") + rescue ArgumentError => e + assert_equal 'expected a time or date, got ""', e.message, "ensure ArgumentError is not being raised by dependencies.rb" + rescue Exception + flunk("ArgumentError should be raised, but we got #{$!.class} instead") + end + end end -- cgit v1.2.3