Search code examples
methodsargument-error

Why does ruby koans accept the exception message in line 5 but not in line 10?


1. def test_calling_global_methods_with_wrong_number_of_arguments
2.    exception = assert_raise(ArgumentError) do
3.      my_global_method
4.    end
5.    assert_match(/wrong number of arguments \(0 for 2\)/, exception.message)
6.
7.    exception = assert_raise(ArgumentError) do
8.      my_global_method(1,2,3)
9.    end
10.   assert_match(/wrong number or arguments \(3 for 2\)/, exception.message)
11. end

line 5 worked perfectly. But when i make the same edit in line 10, why do i get the error message saying: Expected "wrong number of arguments (3 for 2)" to match /wrong number or arguments \(3 for 2\)/

Am i missing something?


Solution

  • You have a typo in the assertion in line 10, 'or' instead of 'of'

    wrong number or arguments