aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-12-15 02:28:20 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-12-15 02:28:20 +0000
commitaa4ad404c6aa4feccc69b8d7222bcfd1b1903215 (patch)
treef2d665ca4f0ca0be949eb6db96d8b3816dab5600 /activesupport/test
parentcefea3c677f90b2c095b377f1ba36a3ff157f5b0 (diff)
downloadrails-aa4ad404c6aa4feccc69b8d7222bcfd1b1903215.tar.gz
rails-aa4ad404c6aa4feccc69b8d7222bcfd1b1903215.tar.bz2
rails-aa4ad404c6aa4feccc69b8d7222bcfd1b1903215.zip
Ruby 1.9 compat: shadowed vars, kcode
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8402 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb6
-rw-r--r--activesupport/test/core_ext/module/attribute_aliasing_test.rb8
-rw-r--r--activesupport/test/json/encoding_test.rb22
3 files changed, 26 insertions, 10 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index 3763f47c68..4d01faa5d2 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -145,7 +145,7 @@ class HashExtTest < Test::Unit::TestCase
assert_equal updated_with_mixed[:a], 1
assert_equal updated_with_mixed['b'], 2
- assert [updated_with_strings, updated_with_symbols, updated_with_mixed].all? {|hash| hash.keys.size == 2}
+ assert [updated_with_strings, updated_with_symbols, updated_with_mixed].all? { |h| h.keys.size == 2 }
end
def test_indifferent_merging
@@ -371,8 +371,8 @@ class HashToXmlTest < Test::Unit::TestCase
end
def test_one_level_with_yielding
- xml = { :name => "David", :street => "Paulina" }.to_xml(@xml_options) do |xml|
- xml.creator("Rails")
+ xml = { :name => "David", :street => "Paulina" }.to_xml(@xml_options) do |x|
+ x.creator("Rails")
end
assert_equal "<person>", xml.first(8)
diff --git a/activesupport/test/core_ext/module/attribute_aliasing_test.rb b/activesupport/test/core_ext/module/attribute_aliasing_test.rb
index 05f7a5c4ca..bd23879513 100644
--- a/activesupport/test/core_ext/module/attribute_aliasing_test.rb
+++ b/activesupport/test/core_ext/module/attribute_aliasing_test.rb
@@ -3,11 +3,15 @@ require File.dirname(__FILE__) + '/../../abstract_unit'
module AttributeAliasing
class Content
attr_accessor :title, :Data
-
+
+ def initialize
+ @title, @Data = nil, nil
+ end
+
def title?
!title.nil?
end
-
+
def Data?
!self.Data.nil?
end
diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb
index bf1b9893cb..4e4fe5703e 100644
--- a/activesupport/test/json/encoding_test.rb
+++ b/activesupport/test/json/encoding_test.rb
@@ -53,11 +53,10 @@ class TestJSONEncoding < Test::Unit::TestCase
end
def test_utf8_string_encoded_properly_when_kcode_is_utf8
- old_kcode, $KCODE = $KCODE, 'UTF8'
- assert_equal '"\\u20ac2.99"', '€2.99'.to_json
- assert_equal '"\\u270e\\u263a"', '✎☺'.to_json
- ensure
- $KCODE = old_kcode
+ with_kcode 'UTF8' do
+ assert_equal '"\\u20ac2.99"', '€2.99'.to_json
+ assert_equal '"\\u270e\\u263a"', '✎☺'.to_json
+ end
end
def test_exception_raised_when_encoding_circular_reference
@@ -80,6 +79,19 @@ class TestJSONEncoding < Test::Unit::TestCase
end
protected
+ def with_kcode(code)
+ if RUBY_VERSION < '1.9'
+ begin
+ old_kcode, $KCODE = $KCODE, 'UTF8'
+ yield
+ ensure
+ $KCODE = old_kcode
+ end
+ else
+ yield
+ end
+ end
+
def object_keys(json_object)
json_object[1..-2].scan(/([^{}:,\s]+):/).flatten.sort
end