Permalink
Browse files

Fixed errors thrown to namespace collision

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@421 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 2aac6d9 commit 31901a5939d5bfad8ae543724de8de3a069ab26a @dhh dhh committed Jan 15, 2005
Showing with 20 additions and 6 deletions.
  1. +2 −2 activesupport/lib/core_ext/numeric/time.rb
  2. +18 −4 activesupport/test/core_ext/numeric_ext_test.rb
@@ -38,15 +38,15 @@ def years
alias :year :years
# Reads best without arguments: 10.minutes.ago
- def ago(time = Time.now)
+ def ago(time = ::Time.now)
time - self
end
# Reads best with argument: 10.minutes.until(time)
alias :until :ago
# Reads best with argument: 10.minutes.since(time)
- def since(time = Time.now)
+ def since(time = ::Time.now)
time + self
end
@@ -13,17 +13,31 @@ def setup
}
end
- def test_time_units
+ def test_units
@seconds.each do |actual, expected|
assert_equal expected, actual
- assert_equal expected.since(@now), @now + actual
- assert_equal expected.until(@now), @now - actual
+ end
+ end
+
+ def test_intervals
+ @seconds.values.each do |seconds|
+ assert_equal seconds.since(@now), @now + seconds
+ assert_equal seconds.until(@now), @now - seconds
+ end
+ end
+
+ # Test intervals based from Time.now
+ def test_now
+ @seconds.values.each do |seconds|
+ now = Time.now
+ assert seconds.ago >= now - seconds
+ now = Time.now
+ assert seconds.from_now >= now + seconds
end
end
end
class NumericExtSizeTest < Test::Unit::TestCase
-
def test_unit_in_terms_of_another
relationships = {
1024.kilobytes => 1.megabyte,

0 comments on commit 31901a5

Please sign in to comment.