From d8d1d4cc64a8d4620458f02782e7d7cd12abd96a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 17 Mar 2009 21:38:05 -0400 Subject: [PATCH] Provided an alternative test_hash_keys_and_values function. Asserts on hash.keys or hash.values can not be relied on as the order is random (I had an expected values of [:two, :one] when I got to that test). --- koans/about_hashes.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/koans/about_hashes.rb b/koans/about_hashes.rb index 6208f38..634323a 100644 --- a/koans/about_hashes.rb +++ b/koans/about_hashes.rb @@ -38,10 +38,17 @@ class AboutHashes < EdgeCase::Koan assert_equal hash1, hash2 end - def test_hash_keys_and_values + def test_hash_keys_and_values hash = { :one => "uno", :two => "dos" } - assert_equal __, hash.keys - assert_equal __, hash.values + + assert_equal __, hash.keys.size + assert_equal __, hash.has_key?(:one) + + # Why not just compare hash.keys to [:one, :two]? + # + # Clue: What was the name of the previous test again? + + assert_equal __, hash.values.sort end def test_combining_hashes