For newer versions of Ruby "assert_raise(KeyError) do" is the correct answer. However, IndexError is the parent of KeyError, so your answer would work as well.