• Even adding tests for a single additional word would prevent this.

    Instead of just:

    Test.assert_equals(greet.(spoken, "Hello"), "Hello.")
    Test.assert_equals(greet.(shouted, "Hello"), "HELLO!")
    Test.assert_equals(greet.(whispered, "Hello"), "hello.")
    

    You could add:

    Test.assert_equals(greet.(spoken, "Hola"), "Hola.")
    Test.assert_equals(greet.(shouted, "Hola"), "HOLA!")
    Test.assert_equals(greet.(whispered, "Hola"), "hola.")
    

    This alone would prevent much hardcoding. If you wanted to be more robust you could have an array of words and randomly select some (10 or so?) to run your three tests with. That way, each time the tests were run the kata solver would be presented with an entirely new set of words, completely eliminating the possibility for my variety of 'cheating'.

  • I'd like to think that rather than "cheating myself", I'm merely pointing out holes in your tests. If you'd like to prevent this kind of hardcoding in your kata's solutions, I suggest writing additional tests that expect properly formatted output from various greetings.