Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Test::Unit assert_throws

Reply
Thread Tools

Test::Unit assert_throws

 
 
asplake
Guest
Posts: n/a
 
      01-01-2006
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

 
Reply With Quote
 
 
 
 
George Ogata
Guest
Posts: n/a
 
      01-02-2006
"asplake" <> writes:

> 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
end

def g
raise
end

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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
minitest assert_throws, why rescue? Intransition Ruby 2 09-02-2009 02:25 PM
Assert_throws Peter Fitzgibbons Ruby 2 09-12-2005 07:26 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57