Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stuck on about_methods.rb on the EdgeCase Ruby Koans

Tags:

ruby

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
like image 780
jbfink Avatar asked Aug 31 '10 20:08

jbfink


2 Answers

Try removing the quotes from the regex:

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

like image 196
zetetic Avatar answered Dec 01 '22 05:12

zetetic


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.

like image 45
steenslag Avatar answered Dec 01 '22 06:12

steenslag