Handle 1.8 VS 1.9 differences in fetch exception.
authorJim Weirich <jim.weirich@gmail.com>
Sun, 4 Dec 2011 07:03:10 +0000 (02:03 -0500)
committerJim Weirich <jim.weirich@gmail.com>
Sun, 4 Dec 2011 07:03:10 +0000 (02:03 -0500)
src/about_hashes.rb
src/edgecase.rb

index 0915fa6..27a6fd1 100644 (file)
@@ -23,7 +23,7 @@ class AboutHashes < EdgeCase::Koan
   def test_accessing_hashes_with_fetch
     hash = { :one => "uno" }
     assert_equal "uno", hash.fetch(:one)
-    assert_raise(___(IndexError)) do
+    assert_raise(___(IndexError, KeyError)) do
       hash.fetch(:doesnt_exist)
     end
 
index 0707687..1136218 100644 (file)
@@ -44,8 +44,12 @@ def _n_(value=999999, value19=:mu)
 end
 
 # Error object replacement value.
-def ___(value=FillMeInError)
-  value
+def ___(value=FillMeInError, value19=:mu)
+  if RUBY_VERSION < "1.9"
+    value
+  else
+    (value19 == :mu) ? value : value19
+  end
 end
 
 # Method name replacement.