diff options
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/abstract_unit.rb | 11 | ||||
-rw-r--r-- | activesupport/test/callback_inheritance_test.rb | 1 | ||||
-rw-r--r-- | activesupport/test/callbacks_test.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/class/delegating_attributes_test.rb | 22 | ||||
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 4 | ||||
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 14 | ||||
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 2 | ||||
-rw-r--r-- | activesupport/test/dependencies_test.rb | 2 | ||||
-rw-r--r-- | activesupport/test/flush_cache_on_private_memoization_test.rb | 1 | ||||
-rw-r--r-- | activesupport/test/inflector_test_cases.rb | 16 | ||||
-rw-r--r-- | activesupport/test/notifications_test.rb | 6 | ||||
-rw-r--r-- | activesupport/test/ts_isolated.rb | 2 |
12 files changed, 54 insertions, 29 deletions
diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index da338a2a26..67f652325e 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -1,10 +1,17 @@ -require File.expand_path('../../../load_paths', __FILE__) +begin + old, $VERBOSE = $VERBOSE, nil + require File.expand_path('../../../load_paths', __FILE__) +ensure + $VERBOSE = old +end lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") $:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) require 'test/unit' -require 'mocha' +require 'active_support/core_ext/kernel/reporting' + +silence_warnings { require 'mocha' } ENV['NO_RELOAD'] = '1' require 'active_support' diff --git a/activesupport/test/callback_inheritance_test.rb b/activesupport/test/callback_inheritance_test.rb index e74c64ba8d..8caf000c5d 100644 --- a/activesupport/test/callback_inheritance_test.rb +++ b/activesupport/test/callback_inheritance_test.rb @@ -1,3 +1,4 @@ +require 'abstract_unit' require 'test/unit' require 'active_support' diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb index 3fb940ad3c..49d9de63b0 100644 --- a/activesupport/test/callbacks_test.rb +++ b/activesupport/test/callbacks_test.rb @@ -1,4 +1,4 @@ -# require 'abstract_unit' +require 'abstract_unit' require 'test/unit' require 'active_support' diff --git a/activesupport/test/core_ext/class/delegating_attributes_test.rb b/activesupport/test/core_ext/class/delegating_attributes_test.rb index 636edb8d4b..6d6cb61571 100644 --- a/activesupport/test/core_ext/class/delegating_attributes_test.rb +++ b/activesupport/test/core_ext/class/delegating_attributes_test.rb @@ -11,6 +11,13 @@ module DelegatingFixtures class Mokopuna < Child end + + class PercysMom + superclass_delegating_accessor :superpower + end + + class Percy < PercysMom + end end class DelegatingAttributesTest < Test::Unit::TestCase @@ -70,18 +77,17 @@ class DelegatingAttributesTest < Test::Unit::TestCase end def test_delegation_stops_at_the_right_level - assert_nil Mokopuna.some_attribute - assert_nil Child.some_attribute - Child.some_attribute="1" - assert_equal "1", Mokopuna.some_attribute - ensure - Child.some_attribute=nil + assert_nil Percy.superpower + assert_nil PercysMom.superpower + + PercysMom.superpower = :heatvision + assert_equal :heatvision, Percy.superpower end - + def test_delegation_stops_for_nil Mokopuna.some_attribute = nil Child.some_attribute="1" - + assert_equal "1", Child.some_attribute assert_nil Mokopuna.some_attribute ensure diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 5b1d53ac7b..86272a28c1 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -757,6 +757,7 @@ class HashToXmlTest < Test::Unit::TestCase <expires-at type="dateTime">2007-12-25T12:34:56+0000</expires-at> <notes type="string"></notes> <illustration type="base64Binary">YmFiZS5wbmc=</illustration> + <caption type="binary" encoding="base64">VGhhdCdsbCBkbywgcGlnLg==</caption> </bacon> EOT @@ -766,7 +767,8 @@ class HashToXmlTest < Test::Unit::TestCase :price => BigDecimal("12.50"), :expires_at => Time.utc(2007,12,25,12,34,56), :notes => "", - :illustration => "babe.png" + :illustration => "babe.png", + :caption => "That'll do, pig." }.stringify_keys assert_equal expected_bacon_hash, Hash.from_xml(bacon_xml)["bacon"] diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index 9edd7cc7c0..1712b0649b 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -141,6 +141,20 @@ class ModuleTest < Test::Unit::TestCase assert_equal 0.0, nil_project.to_f end + def test_delegation_does_not_raise_error_when_removing_singleton_instance_methods + parent = Class.new do + def self.parent_method; end + end + + assert_nothing_raised do + child = Class.new(parent) do + class << self + delegate :parent_method, :to => :superclass + end + end + end + end + def test_parent assert_equal Yz::Zy, Yz::Zy::Cd.parent assert_equal Yz, Yz::Zy.parent diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index a50e259726..234e41c772 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -285,7 +285,7 @@ class TestGetTextString < Test::Unit::TestCase def test_percent assert_equal("% 1", "%% %<num>d" % {:num => 1.0}) - assert_equal("%{num} %<num>d", "%%{num} %%<num>d" % {:num => 1}) + assert_equal("%{num} %<num>d 1", "%%{num} %%<num>d %<num>d" % {:num => 1}) end def test_sprintf_percent_in_replacement diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 6ff6dfb607..2cbf9e5042 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -88,7 +88,7 @@ class DependenciesTest < Test::Unit::TestCase old_warnings, ActiveSupport::Dependencies.warnings_on_first_load = ActiveSupport::Dependencies.warnings_on_first_load, true filename = "check_warnings" - expanded = File.expand_path("test/dependencies/#{filename}") + expanded = File.expand_path("#{File.dirname(__FILE__)}/dependencies/#{filename}") $check_warnings_load_count = 0 assert !ActiveSupport::Dependencies.loaded.include?(expanded) diff --git a/activesupport/test/flush_cache_on_private_memoization_test.rb b/activesupport/test/flush_cache_on_private_memoization_test.rb index 1cd313ec81..91b856ed7c 100644 --- a/activesupport/test/flush_cache_on_private_memoization_test.rb +++ b/activesupport/test/flush_cache_on_private_memoization_test.rb @@ -1,3 +1,4 @@ +require 'abstract_unit' require 'active_support' require 'test/unit' diff --git a/activesupport/test/inflector_test_cases.rb b/activesupport/test/inflector_test_cases.rb index ebd26d3fc6..56372903f3 100644 --- a/activesupport/test/inflector_test_cases.rb +++ b/activesupport/test/inflector_test_cases.rb @@ -180,18 +180,10 @@ module InflectorTestCases "Test with + sign" => "test_with_sign" } - # Ruby 1.9 doesn't do Unicode normalization yet. - if RUBY_VERSION >= '1.9' - StringToParameterizedAndNormalized = { - "Malmö" => "malm", - "Garçons" => "gar-ons" - } - else - StringToParameterizedAndNormalized = { - "Malmö" => "malmo", - "Garçons" => "garcons" - } - end + StringToParameterizedAndNormalized = { + "Malmö" => "malmo", + "Garçons" => "garcons" + } UnderscoreToHuman = { "employee_salary" => "Employee salary", diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb index 67c3527e23..92fbe5b92f 100644 --- a/activesupport/test/notifications_test.rb +++ b/activesupport/test/notifications_test.rb @@ -65,7 +65,7 @@ module Notifications assert_equal [[:foo]] * 4, @events end - def test_log_subscriber_with_pattern + def test_log_subscriber_with_string events = [] @notifier.subscribe('1') { |*args| events << args } @@ -74,10 +74,10 @@ module Notifications @notifier.publish 'a.1' @notifier.wait - assert_equal [['1'], ['1.a']], events + assert_equal [['1']], events end - def test_log_subscriber_with_pattern_as_regexp + def test_log_subscriber_with_pattern events = [] @notifier.subscribe(/\d/) { |*args| events << args } diff --git a/activesupport/test/ts_isolated.rb b/activesupport/test/ts_isolated.rb index cbab61a523..58710e0165 100644 --- a/activesupport/test/ts_isolated.rb +++ b/activesupport/test/ts_isolated.rb @@ -1,3 +1,5 @@ +$:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib') + require 'test/unit' require 'rbconfig' require 'active_support/core_ext/kernel/reporting' |