aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-11-20 08:52:48 +0100
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-11-20 08:52:48 +0100
commit206c5643aae40b0884d42fdb8caeb3f763936fa9 (patch)
tree608f5cc7daab7b58b3d159429c595303e7e1c7d4 /activesupport/test
parentfb1eebac940d0648d1640d20a24f085d901d6f30 (diff)
parent20a346170cf3922d16e265487cfb1abcc85383c1 (diff)
downloadrails-206c5643aae40b0884d42fdb8caeb3f763936fa9.tar.gz
rails-206c5643aae40b0884d42fdb8caeb3f763936fa9.tar.bz2
rails-206c5643aae40b0884d42fdb8caeb3f763936fa9.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/enumerable_test.rb11
-rw-r--r--activesupport/test/core_ext/object_and_class_ext_test.rb25
-rw-r--r--activesupport/test/time_zone_test.rb2
3 files changed, 37 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb
index deb9b7544d..92db977a77 100644
--- a/activesupport/test/core_ext/enumerable_test.rb
+++ b/activesupport/test/core_ext/enumerable_test.rb
@@ -79,4 +79,15 @@ class EnumerableTests < Test::Unit::TestCase
assert ![ 1, 2 ].many? {|x| x > 1 }
assert [ 1, 2, 2 ].many? {|x| x > 1 }
end
+
+ def test_none
+ assert [].none?
+ assert [nil, false].none?
+ assert ![1].none?
+
+ assert [].none? {|x| x > 1 }
+ assert ![ 2 ].none? {|x| x > 1 }
+ assert ![ 1, 2 ].none? {|x| x > 1 }
+ assert [ 1, 1 ].none? {|x| x > 1 }
+ end
end
diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb
index e88dcb52d5..fbdce56ac2 100644
--- a/activesupport/test/core_ext/object_and_class_ext_test.rb
+++ b/activesupport/test/core_ext/object_and_class_ext_test.rb
@@ -247,3 +247,28 @@ class ObjectInstanceVariableTest < Test::Unit::TestCase
[arg] + instance_exec('bar') { |v| [reverse, v] } }
end
end
+
+class ObjectTryTest < Test::Unit::TestCase
+ def setup
+ @string = "Hello"
+ end
+
+ def test_nonexisting_method
+ method = :undefined_method
+ assert !@string.respond_to?(method)
+ assert_nil @string.try(method)
+ end
+
+ def test_valid_method
+ assert_equal 5, @string.try(:size)
+ end
+
+ def test_valid_private_method
+ class << @string
+ private :size
+ end
+
+ assert_equal 5, @string.try(:size)
+ end
+
+end
diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb
index d999b9f2a8..60313dc2f7 100644
--- a/activesupport/test/time_zone_test.rb
+++ b/activesupport/test/time_zone_test.rb
@@ -51,7 +51,7 @@ class TimeZoneTest < Test::Unit::TestCase
define_method("test_utc_offset_for_#{name}") do
silence_warnings do # silence warnings raised by tzinfo gem
- period = zone.tzinfo.period_for_utc(Time.utc(2009,1,1,0,0,0))
+ period = zone.tzinfo.current_period
assert_equal period.utc_offset, zone.utc_offset
end
end