Browse files

Fix OrderedHash#inspect recursion

  • Loading branch information...
1 parent 638b3b1 commit 9d13b9eed8652b85df11294d8135bbfc36a86563 @jeremy jeremy committed Mar 4, 2009
Showing with 8 additions and 2 deletions.
  1. +1 −1 activesupport/lib/active_support/ordered_hash.rb
  2. +7 −1 activesupport/test/ordered_hash_test.rb
View
2 activesupport/lib/active_support/ordered_hash.rb
@@ -93,7 +93,7 @@ def merge(other_hash)
end
def inspect
- "#<OrderedHash #{self.to_hash.inspect}>"
+ "#<OrderedHash #{super}>"
end
private
View
8 activesupport/test/ordered_hash_test.rb
@@ -4,9 +4,11 @@ class OrderedHashTest < Test::Unit::TestCase
def setup
@keys = %w( blue green red pink orange )
@values = %w( 000099 009900 aa0000 cc0066 cc6633 )
+ @hash = Hash.new
@ordered_hash = ActiveSupport::OrderedHash.new
@keys.each_with_index do |key, index|
+ @hash[key] = @values[index]
@ordered_hash[key] = @values[index]
end
end
@@ -17,7 +19,7 @@ def test_order
end
def test_access
- assert @keys.zip(@values).all? { |k, v| @ordered_hash[k] == v }
+ assert @hash.all? { |k, v| @ordered_hash[k] == v }
end
def test_assignment
@@ -152,4 +154,8 @@ def test_keys
@ordered_hash.keys.pop
assert_equal original, @ordered_hash.keys
end
+
+ def test_inspect
+ assert @ordered_hash.inspect.include?(@hash.inspect)
+ end
end

0 comments on commit 9d13b9e

Please sign in to comment.