Stuck on about_methods.rb on EdgeCase Ruby Koans

I hack my way through EdgeCase RubyKoans (www.rubykoans.com) and delay the method starting at line 35 in about_methods.rb here . Running rake is unpredictable and tells me to look at line 36. I'm sure I have assert_match correctly ("0 for 2"), but I don't know what happened. It is very possible that the line assert_raise (___) should have something between the parentheses, but I have no idea what it should be. Any hints or boosts? Many thanks.

edit: here is a short piece of code:

def my_global_method(a,b) a + b end 

-snip -

 def test_calling_global_methods_with_wrong_number_of_arguments exception = assert_raise(___) do my_global_method end assert_match(/"0 for 2"/, exception.message) exception = assert_raise(___) do my_global_method(1,2,3) end assert_match(/__/, exception.message) end 
+6
ruby
source share
3 answers
 exception = assert_raise(___) do 

You must substitute underscores with the error you expect to receive. Error is an object - which object? And what zetetic said, the regex is wrong.

+4
source share

Try removing quotes from the regular expression:

assert_match(/0 for 2/, exception.message)

+7
source share

I just did a test,

With a regular expression with parentheses, you are supposed to use a backslash or meet zero.

 def test_calling_global_methods_with_wrong_number_of_arguments exception = assert_raise(ArgumentError) do my_global_method end assert_match(/wrong number of arguments \(0 for 2\)/, exception.message) exception = assert_raise(___) do my_global_method(1,2,3) end assert_match(/__/, exception.message) 

end

or just fill it out (o for 2) \

both words ~!

0
source share

All Articles