views:

50

answers:

2

I'm hacking my way through the EdgeCase RubyKoans (www.rubykoans.com) and am stuck on the method starting at line 35 in about_methods.rb here. Running rake fails predictably and tells me to look at line 36. I'm reasonable sure I have the assert_match correct ("0 for 2") but I don't know what's failing. It's very possible that the assert_raise(_) line should have something inbetween the parentheses, but I have no idea what that should be. Any hints or nudges? Thanks much.

edit: here's the short snippet of offending 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
+1  A: 

Try removing the quotes from the regex:

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

zetetic
D'oh, yes, I actually did have the regex without quotes originally -- thanks for catching that!
jbfink
+1  A: 
exception = assert_raise(___) do

You're supposed to substitute the underscores with the error you expect to be raised. The error is an object - what kind of object? And what zetetic said, the regex is incorrect.

steenslag
Hah! Got it! Thanks so much!
jbfink