Handle 1.8 VS 1.9 differences in fetch exception.

This commit is contained in:
Jim Weirich
2011-12-04 02:03:10 -05:00
parent 6592f3d36e
commit 5665cb0366
2 changed files with 7 additions and 3 deletions

View File

@@ -23,7 +23,7 @@ class AboutHashes < EdgeCase::Koan
def test_accessing_hashes_with_fetch def test_accessing_hashes_with_fetch
hash = { :one => "uno" } hash = { :one => "uno" }
assert_equal "uno", hash.fetch(:one) assert_equal "uno", hash.fetch(:one)
assert_raise(___(IndexError)) do assert_raise(___(IndexError, KeyError)) do
hash.fetch(:doesnt_exist) hash.fetch(:doesnt_exist)
end end

View File

@@ -44,8 +44,12 @@ def _n_(value=999999, value19=:mu)
end end
# Error object replacement value. # Error object replacement value.
def ___(value=FillMeInError) def ___(value=FillMeInError, value19=:mu)
if RUBY_VERSION < "1.9"
value value
else
(value19 == :mu) ? value : value19
end
end end
# Method name replacement. # Method name replacement.