aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/class_test.rb6
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb26
-rw-r--r--activesupport/test/core_ext/load_error_test.rb4
-rw-r--r--activesupport/test/core_ext/module/synchronization_test.rb4
-rw-r--r--activesupport/test/core_ext/module_test.rb10
-rw-r--r--activesupport/test/core_ext/object_and_class_ext_test.rb4
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb18
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb2
8 files changed, 57 insertions, 17 deletions
diff --git a/activesupport/test/core_ext/class_test.rb b/activesupport/test/core_ext/class_test.rb
index 9c6071d478..48d8a78acf 100644
--- a/activesupport/test/core_ext/class_test.rb
+++ b/activesupport/test/core_ext/class_test.rb
@@ -19,19 +19,19 @@ class ClassTest < Test::Unit::TestCase
def test_removing_class_in_root_namespace
assert A.is_a?(Class)
Class.remove_class(A)
- assert_raises(NameError) { A.is_a?(Class) }
+ assert_raise(NameError) { A.is_a?(Class) }
end
def test_removing_class_in_one_level_namespace
assert X::B.is_a?(Class)
Class.remove_class(X::B)
- assert_raises(NameError) { X::B.is_a?(Class) }
+ assert_raise(NameError) { X::B.is_a?(Class) }
end
def test_removing_class_in_two_level_namespace
assert Y::Z::C.is_a?(Class)
Class.remove_class(Y::Z::C)
- assert_raises(NameError) { Y::Z::C.is_a?(Class) }
+ assert_raise(NameError) { Y::Z::C.is_a?(Class) }
end
def test_retrieving_subclasses
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index b63ab30965..0edac72fe7 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -174,6 +174,13 @@ class HashExtTest < Test::Unit::TestCase
assert_equal 2, hash['b']
end
+ def test_indifferent_reverse_merging
+ hash = HashWithIndifferentAccess.new('some' => 'value', 'other' => 'value')
+ hash.reverse_merge!(:some => 'noclobber', :another => 'clobber')
+ assert_equal 'value', hash[:some]
+ assert_equal 'clobber', hash[:another]
+ end
+
def test_indifferent_deleting
get_hash = proc{ { :a => 'foo' }.with_indifferent_access }
hash = get_hash.call
@@ -234,7 +241,7 @@ class HashExtTest < Test::Unit::TestCase
{ :failure => "stuff", :funny => "business" }.assert_valid_keys(:failure, :funny)
end
- assert_raises(ArgumentError, "Unknown key(s): failore") do
+ assert_raise(ArgumentError, "Unknown key(s): failore") do
{ :failore => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ])
{ :failore => "stuff", :funny => "business" }.assert_valid_keys(:failure, :funny)
end
@@ -490,6 +497,15 @@ class HashToXmlTest < Test::Unit::TestCase
assert xml.include?(%(<addresses type="array"><address><streets type="array"><street><name>))
end
+ def test_timezoned_attributes
+ xml = {
+ :created_at => Time.utc(1999,2,2),
+ :local_created_at => Time.utc(1999,2,2).in_time_zone('Eastern Time (US & Canada)')
+ }.to_xml(@xml_options)
+ assert_match %r{<created-at type=\"datetime\">1999-02-02T00:00:00Z</created-at>}, xml
+ assert_match %r{<local-created-at type=\"datetime\">1999-02-01T19:00:00-05:00</local-created-at>}, xml
+ end
+
def test_single_record_from_xml
topic_xml = <<-EOT
<topic>
@@ -884,7 +900,13 @@ class QueryTest < Test::Unit::TestCase
end
def test_expansion_count_is_limited
- assert_raises RuntimeError do
+ expected = {
+ 'ActiveSupport::XmlMini_REXML' => 'RuntimeError',
+ 'ActiveSupport::XmlMini_Nokogiri' => 'Nokogiri::XML::SyntaxError',
+ 'ActiveSupport::XmlMini_LibXML' => 'LibXML::XML::Error',
+ }[ActiveSupport::XmlMini.backend.name].constantize
+
+ assert_raise expected do
attack_xml = <<-EOT
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE member [
diff --git a/activesupport/test/core_ext/load_error_test.rb b/activesupport/test/core_ext/load_error_test.rb
index 5bb5b4d1b8..cfa8f978af 100644
--- a/activesupport/test/core_ext/load_error_test.rb
+++ b/activesupport/test/core_ext/load_error_test.rb
@@ -2,10 +2,10 @@ require 'abstract_unit'
class TestMissingSourceFile < Test::Unit::TestCase
def test_with_require
- assert_raises(MissingSourceFile) { require 'no_this_file_don\'t_exist' }
+ assert_raise(MissingSourceFile) { require 'no_this_file_don\'t_exist' }
end
def test_with_load
- assert_raises(MissingSourceFile) { load 'nor_does_this_one' }
+ assert_raise(MissingSourceFile) { load 'nor_does_this_one' }
end
def test_path
begin load 'nor/this/one.rb'
diff --git a/activesupport/test/core_ext/module/synchronization_test.rb b/activesupport/test/core_ext/module/synchronization_test.rb
index b1d4bc5e06..c28bc9b073 100644
--- a/activesupport/test/core_ext/module/synchronization_test.rb
+++ b/activesupport/test/core_ext/module/synchronization_test.rb
@@ -28,14 +28,14 @@ class SynchronizationTest < Test::Unit::TestCase
end
def test_synchronize_with_no_mutex_raises_an_argument_error
- assert_raises(ArgumentError) do
+ assert_raise(ArgumentError) do
@target.synchronize :to_s
end
end
def test_double_synchronize_raises_an_argument_error
@target.synchronize :to_s, :with => :mutex
- assert_raises(ArgumentError) do
+ assert_raise(ArgumentError) do
@target.synchronize :to_s, :with => :mutex
end
end
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb
index a5d98507ba..0d3d10f333 100644
--- a/activesupport/test/core_ext/module_test.rb
+++ b/activesupport/test/core_ext/module_test.rb
@@ -92,8 +92,8 @@ class ModuleTest < Test::Unit::TestCase
end
def test_missing_delegation_target
- assert_raises(ArgumentError) { eval($nowhere) }
- assert_raises(ArgumentError) { eval($noplace) }
+ assert_raise(ArgumentError) { eval($nowhere) }
+ assert_raise(ArgumentError) { eval($noplace) }
end
def test_delegation_prefix
@@ -141,7 +141,7 @@ class ModuleTest < Test::Unit::TestCase
def test_delegation_without_allow_nil_and_nil_value
david = Someone.new("David")
- assert_raises(NoMethodError) { david.street }
+ assert_raise(NoMethodError) { david.street }
end
def test_parent
@@ -314,7 +314,7 @@ class MethodAliasingTest < Test::Unit::TestCase
alias_method_chain :duck, :orange
end
- assert_raises NoMethodError do
+ assert_raise NoMethodError do
@instance.duck
end
@@ -330,7 +330,7 @@ class MethodAliasingTest < Test::Unit::TestCase
alias_method_chain :duck, :orange
end
- assert_raises NoMethodError do
+ assert_raise NoMethodError do
@instance.duck
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 0bdbd14f33..b6515e05a0 100644
--- a/activesupport/test/core_ext/object_and_class_ext_test.rb
+++ b/activesupport/test/core_ext/object_and_class_ext_test.rb
@@ -109,7 +109,7 @@ end
class ObjectTests < Test::Unit::TestCase
def test_suppress_re_raises
- assert_raises(LoadError) { suppress(ArgumentError) {raise LoadError} }
+ assert_raise(LoadError) { suppress(ArgumentError) {raise LoadError} }
end
def test_suppress_supresses
suppress(ArgumentError) { raise ArgumentError }
@@ -256,7 +256,7 @@ class ObjectTryTest < Test::Unit::TestCase
def test_nonexisting_method
method = :undefined_method
assert !@string.respond_to?(method)
- assert_raises(NoMethodError) { @string.try(method) }
+ assert_raise(NoMethodError) { @string.try(method) }
end
def test_valid_method
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index e232bf8384..6c9b7e7236 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -77,6 +77,24 @@ class StringInflectionsTest < Test::Unit::TestCase
end
end
+ def test_string_parameterized_normal
+ StringToParameterized.each do |normal, slugged|
+ assert_equal(normal.parameterize, slugged)
+ end
+ end
+
+ def test_string_parameterized_no_separator
+ StringToParameterizeWithNoSeparator.each do |normal, slugged|
+ assert_equal(normal.parameterize(''), slugged)
+ end
+ end
+
+ def test_string_parameterized_underscore
+ StringToParameterizeWithUnderscore.each do |normal, slugged|
+ assert_equal(normal.parameterize('_'), slugged)
+ end
+ end
+
def test_humanize
UnderscoreToHuman.each do |underscore, human|
assert_equal(human, underscore.humanize)
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index 1de6a2ac2e..accfe51ed6 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -751,7 +751,7 @@ class TimeWithZoneMethodsForTimeAndDateTimeTest < Test::Unit::TestCase
def test_use_zone_with_exception_raised
Time.zone = 'Alaska'
- assert_raises RuntimeError do
+ assert_raise RuntimeError do
Time.use_zone('Hawaii') { raise RuntimeError }
end
assert_equal ActiveSupport::TimeZone['Alaska'], Time.zone