aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/abstract_unit.rb17
-rw-r--r--activesupport/test/caching_test.rb6
-rw-r--r--activesupport/test/core_ext/boolean_ext_test.rb12
-rw-r--r--activesupport/test/core_ext/enumerable_test.rb12
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb41
-rw-r--r--activesupport/test/core_ext/integer_ext_test.rb16
-rw-r--r--activesupport/test/core_ext/nil_ext_test.rb8
-rw-r--r--activesupport/test/core_ext/object/to_param_test.rb19
-rw-r--r--activesupport/test/core_ext/object/to_query_test.rb43
-rw-r--r--activesupport/test/core_ext/object_and_class_ext_test.rb7
-rw-r--r--activesupport/test/core_ext/object_ext_test.rb16
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb27
-rw-r--r--activesupport/test/core_ext/symbol_test.rb9
-rw-r--r--activesupport/test/core_ext/uri_ext_test.rb8
-rw-r--r--activesupport/test/dependencies_test.rb1
-rw-r--r--activesupport/test/multibyte_chars_test.rb88
-rw-r--r--activesupport/test/multibyte_utils_test.rb1
-rw-r--r--activesupport/test/ordered_hash_test.rb7
-rw-r--r--activesupport/test/ts_isolated.rb4
19 files changed, 168 insertions, 174 deletions
diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb
index f390c66838..dda139372e 100644
--- a/activesupport/test/abstract_unit.rb
+++ b/activesupport/test/abstract_unit.rb
@@ -1,22 +1,15 @@
ORIG_ARGV = ARGV.dup
-root = File.expand_path('../../..', __FILE__)
+
begin
- require "#{root}/vendor/gems/environment"
+ require File.expand_path('../../../vendor/gems/environment', __FILE__)
rescue LoadError
- $:.unshift("#{root}/activesupport/lib")
- $:.unshift("#{root}/activerecord/lib")
end
+lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
+$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require 'test/unit'
-
-begin
- require 'mocha'
-rescue LoadError
- $stderr.puts 'Loading rubygems'
- require 'rubygems'
- require 'mocha'
-end
+require 'mocha'
ENV['NO_RELOAD'] = '1'
require 'active_support'
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index 892aa97ad7..6a51ce9402 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -154,13 +154,13 @@ class FileStoreTest < ActiveSupport::TestCase
File.stubs(:mtime).returns(time)
@cache.write('foo', 'bar')
- cache_read = lambda { @cache.read('foo', :expires_in => 1.minute) }
+ cache_read = lambda { @cache.read('foo', :expires_in => 60) }
assert_equal 'bar', cache_read.call
- Time.stubs(:now).returns(time + 30.seconds)
+ Time.stubs(:now).returns(time + 30)
assert_equal 'bar', cache_read.call
- Time.stubs(:now).returns(time + 2.minutes)
+ Time.stubs(:now).returns(time + 120)
assert_nil cache_read.call
end
end
diff --git a/activesupport/test/core_ext/boolean_ext_test.rb b/activesupport/test/core_ext/boolean_ext_test.rb
deleted file mode 100644
index 9439716efb..0000000000
--- a/activesupport/test/core_ext/boolean_ext_test.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'abstract_unit'
-require 'active_support/core_ext/boolean/conversions'
-
-class BooleanExtAccessTests < Test::Unit::TestCase
- def test_to_param_on_true
- assert_equal true, true.to_param
- end
-
- def test_to_param_on_false
- assert_equal false, false.to_param
- end
-end
diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb
index 4170de3dce..66f5f9fbde 100644
--- a/activesupport/test/core_ext/enumerable_test.rb
+++ b/activesupport/test/core_ext/enumerable_test.rb
@@ -1,6 +1,5 @@
require 'abstract_unit'
require 'active_support/core_ext/array'
-require 'active_support/core_ext/symbol'
require 'active_support/core_ext/enumerable'
Payment = Struct.new(:price)
@@ -90,15 +89,4 @@ 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/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index eb4c37aaf0..4642bb1330 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -899,42 +899,6 @@ class HashToXmlTest < Test::Unit::TestCase
# :builder, etc, shouldn't be added to options
assert_equal({:skip_instruct => true}, options)
end
-end
-
-class QueryTest < Test::Unit::TestCase
- def test_simple_conversion
- assert_query_equal 'a=10', :a => 10
- end
-
- def test_cgi_escaping
- assert_query_equal 'a%3Ab=c+d', 'a:b' => 'c d'
- end
-
- def test_nil_parameter_value
- empty = Object.new
- def empty.to_param; nil end
- assert_query_equal 'a=', 'a' => empty
- end
-
- def test_nested_conversion
- assert_query_equal 'person%5Blogin%5D=seckar&person%5Bname%5D=Nicholas',
- :person => {:name => 'Nicholas', :login => 'seckar'}
- end
-
- def test_multiple_nested
- assert_query_equal 'account%5Bperson%5D%5Bid%5D=20&person%5Bid%5D=10',
- :person => {:id => 10}, :account => {:person => {:id => 20}}
- end
-
- def test_array_values
- assert_query_equal 'person%5Bid%5D%5B%5D=10&person%5Bid%5D%5B%5D=20',
- :person => {:id => [10, 20]}
- end
-
- def test_array_values_are_not_sorted
- assert_query_equal 'person%5Bid%5D%5B%5D=20&person%5Bid%5D%5B%5D=10',
- :person => {:id => [20, 10]}
- end
def test_expansion_count_is_limited
expected = {
@@ -962,9 +926,4 @@ class QueryTest < Test::Unit::TestCase
Hash.from_xml(attack_xml)
end
end
-
- private
- def assert_query_equal(expected, actual, message = nil)
- assert_equal expected.split('&'), actual.to_query.split('&')
- end
end
diff --git a/activesupport/test/core_ext/integer_ext_test.rb b/activesupport/test/core_ext/integer_ext_test.rb
index 956ae5189d..e1591089f5 100644
--- a/activesupport/test/core_ext/integer_ext_test.rb
+++ b/activesupport/test/core_ext/integer_ext_test.rb
@@ -2,22 +2,6 @@ require 'abstract_unit'
require 'active_support/core_ext/integer'
class IntegerExtTest < Test::Unit::TestCase
- def test_even
- assert [ -2, 0, 2, 4 ].all? { |i| i.even? }
- assert ![ -1, 1, 3 ].all? { |i| i.even? }
-
- assert 22953686867719691230002707821868552601124472329079.odd?
- assert !22953686867719691230002707821868552601124472329079.even?
- assert 22953686867719691230002707821868552601124472329080.even?
- assert !22953686867719691230002707821868552601124472329080.odd?
- end
-
- def test_odd
- assert ![ -2, 0, 2, 4 ].all? { |i| i.odd? }
- assert [ -1, 1, 3 ].all? { |i| i.odd? }
- assert 1000000000000000000000000000000000000000000000000000000001.odd?
- end
-
def test_multiple_of
[ -7, 0, 7, 14 ].each { |i| assert i.multiple_of?(7) }
[ -7, 7, 14 ].each { |i| assert ! i.multiple_of?(6) }
diff --git a/activesupport/test/core_ext/nil_ext_test.rb b/activesupport/test/core_ext/nil_ext_test.rb
deleted file mode 100644
index 1062676d65..0000000000
--- a/activesupport/test/core_ext/nil_ext_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'abstract_unit'
-require 'active_support/core_ext/nil/conversions'
-
-class NilExtAccessTests < Test::Unit::TestCase
- def test_to_param
- assert_nil nil.to_param
- end
-end
diff --git a/activesupport/test/core_ext/object/to_param_test.rb b/activesupport/test/core_ext/object/to_param_test.rb
new file mode 100644
index 0000000000..c3efefddb5
--- /dev/null
+++ b/activesupport/test/core_ext/object/to_param_test.rb
@@ -0,0 +1,19 @@
+require 'abstract_unit'
+require 'active_support/core_ext/object/to_param'
+
+class ToParamTest < Test::Unit::TestCase
+ def test_object
+ foo = Object.new
+ def foo.to_s; 'foo' end
+ assert_equal 'foo', foo.to_param
+ end
+
+ def test_nil
+ assert_nil nil.to_param
+ end
+
+ def test_boolean
+ assert_equal true, true.to_param
+ assert_equal false, false.to_param
+ end
+end
diff --git a/activesupport/test/core_ext/object/to_query_test.rb b/activesupport/test/core_ext/object/to_query_test.rb
new file mode 100644
index 0000000000..0fb15be654
--- /dev/null
+++ b/activesupport/test/core_ext/object/to_query_test.rb
@@ -0,0 +1,43 @@
+require 'abstract_unit'
+require 'active_support/core_ext/object/to_query'
+
+class ToQueryTest < Test::Unit::TestCase
+ def test_simple_conversion
+ assert_query_equal 'a=10', :a => 10
+ end
+
+ def test_cgi_escaping
+ assert_query_equal 'a%3Ab=c+d', 'a:b' => 'c d'
+ end
+
+ def test_nil_parameter_value
+ empty = Object.new
+ def empty.to_param; nil end
+ assert_query_equal 'a=', 'a' => empty
+ end
+
+ def test_nested_conversion
+ assert_query_equal 'person%5Blogin%5D=seckar&person%5Bname%5D=Nicholas',
+ :person => {:name => 'Nicholas', :login => 'seckar'}
+ end
+
+ def test_multiple_nested
+ assert_query_equal 'account%5Bperson%5D%5Bid%5D=20&person%5Bid%5D=10',
+ :person => {:id => 10}, :account => {:person => {:id => 20}}
+ end
+
+ def test_array_values
+ assert_query_equal 'person%5Bid%5D%5B%5D=10&person%5Bid%5D%5B%5D=20',
+ :person => {:id => [10, 20]}
+ end
+
+ def test_array_values_are_not_sorted
+ assert_query_equal 'person%5Bid%5D%5B%5D=20&person%5Bid%5D%5B%5D=10',
+ :person => {:id => [20, 10]}
+ end
+
+ private
+ def assert_query_equal(expected, actual, message = nil)
+ assert_equal expected.split('&'), actual.to_query.split('&')
+ 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 f0121b862d..e6fbdb637b 100644
--- a/activesupport/test/core_ext/object_and_class_ext_test.rb
+++ b/activesupport/test/core_ext/object_and_class_ext_test.rb
@@ -182,13 +182,6 @@ class ObjectInstanceVariableTest < Test::Unit::TestCase
assert_equal %w(@bar @baz), @source.instance_variable_names.sort
end
- def test_instance_variable_defined
- assert @source.instance_variable_defined?('@bar')
- assert @source.instance_variable_defined?(:@bar)
- assert !@source.instance_variable_defined?(:@foo)
- assert !@source.instance_variable_defined?('@foo')
- end
-
def test_copy_instance_variables_from_without_explicit_excludes
assert_equal [], @dest.instance_variables
@dest.copy_instance_variables_from(@source)
diff --git a/activesupport/test/core_ext/object_ext_test.rb b/activesupport/test/core_ext/object_ext_test.rb
deleted file mode 100644
index 484eecaab6..0000000000
--- a/activesupport/test/core_ext/object_ext_test.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'abstract_unit'
-require 'active_support/core_ext/object/metaclass'
-require 'active_support/core_ext/object/conversions'
-
-class ObjectExtTest < Test::Unit::TestCase
- def test_tap_yields_and_returns_self
- foo = Object.new
- assert_equal foo, foo.tap { |x| assert_equal foo, x; :bar }
- end
-
- def test_to_param
- foo = Object.new
- foo.class_eval("def to_s; 'foo'; end")
- assert_equal 'foo', foo.to_param
- end
-end
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index 584a41b631..1e8a1c4f08 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -5,6 +5,7 @@ require 'inflector_test_cases'
require 'active_support/core_ext/string'
require 'active_support/core_ext/time'
+require 'active_support/core_ext/kernel/reporting'
class StringInflectionsTest < Test::Unit::TestCase
include InflectorTestCases
@@ -185,17 +186,9 @@ class StringInflectionsTest < Test::Unit::TestCase
assert s.starts_with?('hel')
assert !s.starts_with?('el')
- assert s.start_with?('h')
- assert s.start_with?('hel')
- assert !s.start_with?('el')
-
assert s.ends_with?('o')
assert s.ends_with?('lo')
assert !s.ends_with?('el')
-
- assert s.end_with?('o')
- assert s.end_with?('lo')
- assert !s.end_with?('el')
end
def test_string_squish
@@ -214,17 +207,6 @@ class StringInflectionsTest < Test::Unit::TestCase
# And changes the original string:
assert_equal original, expected
end
-
- if RUBY_VERSION < '1.9'
- def test_each_char_with_utf8_string_when_kcode_is_utf8
- with_kcode('UTF8') do
- '€2.99'.each_char do |char|
- assert_not_equal 1, char.length
- break
- end
- end
- end
- end
end
class StringBehaviourTest < Test::Unit::TestCase
@@ -350,13 +332,6 @@ class TestGetTextString < Test::Unit::TestCase
end
end
-class StringBytesizeTest < Test::Unit::TestCase
- def test_bytesize
- assert_respond_to 'foo', :bytesize
- assert_equal 3, 'foo'.bytesize
- end
-end
-
class OutputSafetyTest < ActiveSupport::TestCase
def setup
@string = "hello"
diff --git a/activesupport/test/core_ext/symbol_test.rb b/activesupport/test/core_ext/symbol_test.rb
deleted file mode 100644
index 1eaccb9965..0000000000
--- a/activesupport/test/core_ext/symbol_test.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require 'abstract_unit'
-
-class SymbolTests < Test::Unit::TestCase
- def test_to_proc
- assert_equal %w(one two three), [:one, :two, :three].map(&:to_s)
- assert_equal(%w(one two three),
- {1 => "one", 2 => "two", 3 => "three"}.sort_by(&:first).map(&:last))
- end
-end
diff --git a/activesupport/test/core_ext/uri_ext_test.rb b/activesupport/test/core_ext/uri_ext_test.rb
index 2d4f38d095..e4a242abc4 100644
--- a/activesupport/test/core_ext/uri_ext_test.rb
+++ b/activesupport/test/core_ext/uri_ext_test.rb
@@ -7,7 +7,11 @@ class URIExtTest < Test::Unit::TestCase
str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese.
str.force_encoding(Encoding::UTF_8) if str.respond_to?(:force_encoding)
- assert_equal str, URI.unescape(URI.escape(str))
- assert_equal str, URI.decode(URI.escape(str))
+ if URI.const_defined?(:Parser)
+ parser = URI::Parser.new
+ assert_equal str, parser.unescape(parser.escape(str))
+ else
+ assert_equal str, URI.unescape(URI.escape(str))
+ end
end
end
diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb
index 97d70cf8c4..0fcf1eaf00 100644
--- a/activesupport/test/dependencies_test.rb
+++ b/activesupport/test/dependencies_test.rb
@@ -3,7 +3,6 @@ require 'pp'
require 'active_support/dependencies'
require 'active_support/core_ext/module/loading'
require 'active_support/core_ext/kernel/reporting'
-require 'active_support/core_ext/symbol/to_proc'
module ModuleWithMissing
mattr_accessor :missing_count
diff --git a/activesupport/test/multibyte_chars_test.rb b/activesupport/test/multibyte_chars_test.rb
index 680936ded5..0e489c10e1 100644
--- a/activesupport/test/multibyte_chars_test.rb
+++ b/activesupport/test/multibyte_chars_test.rb
@@ -100,9 +100,14 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase
def setup
@chars = UNICODE_STRING.dup.mb_chars
- # NEWLINE, SPACE, EM SPACE
- @whitespace = "\n#{[32, 8195].pack('U*')}"
- @whitespace.force_encoding(Encoding::UTF_8) if @whitespace.respond_to?(:force_encoding)
+ if RUBY_VERSION < '1.9'
+ # Multibyte support all kinds of whitespace (ie. NEWLINE, SPACE, EM SPACE)
+ @whitespace = "\n\t#{[32, 8195].pack('U*')}"
+ else
+ # Ruby 1.9 only supports basic whitespace
+ @whitespace = "\n\t ".force_encoding(Encoding::UTF_8)
+ end
+
@byte_order_mark = [65279].pack('U')
end
@@ -163,6 +168,7 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase
assert chars('').strip.kind_of?(ActiveSupport::Multibyte.proxy_class)
assert chars('').reverse.kind_of?(ActiveSupport::Multibyte.proxy_class)
assert chars(' ').slice(0).kind_of?(ActiveSupport::Multibyte.proxy_class)
+ assert chars('').limit(0).kind_of?(ActiveSupport::Multibyte.proxy_class)
assert chars('').upcase.kind_of?(ActiveSupport::Multibyte.proxy_class)
assert chars('').downcase.kind_of?(ActiveSupport::Multibyte.proxy_class)
assert chars('').capitalize.kind_of?(ActiveSupport::Multibyte.proxy_class)
@@ -190,7 +196,9 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase
def test_should_return_character_offset_for_regexp_matches
assert_nil(@chars =~ /wrong/u)
assert_equal 0, (@chars =~ /こ/u)
+ assert_equal 0, (@chars =~ /こに/u)
assert_equal 1, (@chars =~ /に/u)
+ assert_equal 2, (@chars =~ /ち/u)
assert_equal 3, (@chars =~ /わ/u)
end
@@ -220,10 +228,10 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase
assert !@chars.include?('a')
end
- def test_include_raises_type_error_when_nil_is_passed
- assert_raise(TypeError) do
- @chars.include?(nil)
- end
+ def test_include_raises_when_nil_is_passed
+ @chars.include?(nil)
+ flunk "Expected chars.include?(nil) to raise TypeError or NoMethodError"
+ rescue Exception => e
end
def test_index_should_return_character_offset
@@ -378,6 +386,17 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase
assert_equal 'わちにこ', @chars.reverse
end
+ def test_reverse_should_work_with_normalized_strings
+ str = 'bös'
+ reversed_str = 'söb'
+ assert_equal chars(reversed_str).normalize(:kc), chars(str).normalize(:kc).reverse
+ assert_equal chars(reversed_str).normalize(:c), chars(str).normalize(:c).reverse
+ assert_equal chars(reversed_str).normalize(:d), chars(str).normalize(:d).reverse
+ assert_equal chars(reversed_str).normalize(:kd), chars(str).normalize(:kd).reverse
+ assert_equal chars(reversed_str).decompose, chars(str).decompose.reverse
+ assert_equal chars(reversed_str).compose, chars(str).compose.reverse
+ end
+
def test_slice_should_take_character_offsets
assert_equal nil, ''.mb_chars.slice(0)
assert_equal 'こ', @chars.slice(0)
@@ -476,6 +495,43 @@ class MultibyteCharsExtrasTest < Test::Unit::TestCase
end
end
+ def test_limit_should_not_break_on_blank_strings
+ example = chars('')
+ assert_equal example, example.limit(0)
+ assert_equal example, example.limit(1)
+ end
+
+ def test_limit_should_work_on_a_multibyte_string
+ example = chars(UNICODE_STRING)
+ bytesize = UNICODE_STRING.respond_to?(:bytesize) ? UNICODE_STRING.bytesize : UNICODE_STRING.size
+
+ assert_equal UNICODE_STRING, example.limit(bytesize)
+ assert_equal '', example.limit(0)
+ assert_equal '', example.limit(1)
+ assert_equal 'こ', example.limit(3)
+ assert_equal 'こに', example.limit(6)
+ assert_equal 'こに', example.limit(8)
+ assert_equal 'こにち', example.limit(9)
+ assert_equal 'こにちわ', example.limit(50)
+ end
+
+ def test_limit_should_work_on_an_ascii_string
+ ascii = chars(ASCII_STRING)
+ assert_equal ASCII_STRING, ascii.limit(ASCII_STRING.length)
+ assert_equal '', ascii.limit(0)
+ assert_equal 'o', ascii.limit(1)
+ assert_equal 'oh', ascii.limit(2)
+ assert_equal 'ohay', ascii.limit(4)
+ assert_equal 'ohayo', ascii.limit(50)
+ end
+
+ def test_limit_should_keep_under_the_specified_byte_limit
+ example = chars(UNICODE_STRING)
+ (1..UNICODE_STRING.length).each do |limit|
+ assert example.limit(limit).to_s.length <= limit
+ end
+ end
+
def test_composition_exclusion_is_set_up_properly
# Normalization of DEVANAGARI LETTER QA breaks when composition exclusion isn't used correctly
qa = [0x915, 0x93c].pack('U*')
@@ -586,3 +642,21 @@ class MultibyteCharsExtrasTest < Test::Unit::TestCase
end.pack('U*')
end
end
+
+class MultibyteInternalsTest < ActiveSupport::TestCase
+ include MultibyteTestHelpers
+
+ test "Chars translates a character offset to a byte offset" do
+ example = chars("Puisque c'était son erreur, il m'a aidé")
+ [
+ [0, 0],
+ [3, 3],
+ [12, 11],
+ [14, 13],
+ [41, 39]
+ ].each do |byte_offset, character_offset|
+ assert_equal character_offset, example.send(:translate_offset, byte_offset),
+ "Expected byte offset #{byte_offset} to translate to #{character_offset}"
+ end
+ end
+end
diff --git a/activesupport/test/multibyte_utils_test.rb b/activesupport/test/multibyte_utils_test.rb
index 0a2f20d282..1dff944922 100644
--- a/activesupport/test/multibyte_utils_test.rb
+++ b/activesupport/test/multibyte_utils_test.rb
@@ -2,6 +2,7 @@
require 'abstract_unit'
require 'multibyte_test_helpers'
+require 'active_support/core_ext/kernel/reporting'
class MultibyteUtilsTest < ActiveSupport::TestCase
include MultibyteTestHelpers
diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb
index 15bd57181f..1521279437 100644
--- a/activesupport/test/ordered_hash_test.rb
+++ b/activesupport/test/ordered_hash_test.rb
@@ -191,4 +191,11 @@ class OrderedHashTest < Test::Unit::TestCase
assert_equal "odd number of arguments for Hash", $!.message
end
end
+
+ def test_replace_updates_keys
+ @other_ordered_hash = ActiveSupport::OrderedHash[:black, '000000', :white, '000000']
+ original = @ordered_hash.replace(@other_ordered_hash)
+ assert_same original, @ordered_hash
+ assert_equal @other_ordered_hash.keys, @ordered_hash.keys
+ end
end
diff --git a/activesupport/test/ts_isolated.rb b/activesupport/test/ts_isolated.rb
index 9378a13766..cbab61a523 100644
--- a/activesupport/test/ts_isolated.rb
+++ b/activesupport/test/ts_isolated.rb
@@ -8,8 +8,8 @@ class TestIsolated < Test::Unit::TestCase
Dir["#{File.dirname(__FILE__)}/**/*_test.rb"].each do |file|
define_method("test #{file}") do
command = "#{ruby} -Ilib:test #{file}"
- silence_stderr { `#{command}` }
- assert_equal 0, $?.to_i, command
+ result = silence_stderr { `#{command}` }
+ assert_block("#{command}\n#{result}") { $?.to_i.zero? }
end
end
end