Test::Unit assert_throws

A

asplake

Hi,

Any good examples out there (I couldn't find any) of assert_throws? I
would love to know also why its first argument is a symbol...

Thanks
Mike
 
G

George Ogata

asplake said:
Hi,

Any good examples out there (I couldn't find any) of assert_throws? I
would love to know also why its first argument is a symbol...

#assert_throw checks for a Kernel#throw, which takes a Symbol.
Perhaps you were after #assert_raise ?

--------------------

require 'test/unit'

def f
throw :x
end

def g
raise
end

class T < Test::Unit::TestCase
def test_a
assert_throws:)x){f} # pass
assert_throws:)y){f} # fail
end
def test_b
assert_raise(RuntimeError ){g} # pass
assert_raise(ArgumentError){g} # fail
end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top