I am trying to write code like this:
assert_throws(:ExtractionFailed) { unit.extract_from('5 x 2005')}
ExtractionFailed is a trivial subclass of Exception , and when testing / module I try to claim that it throws when I call unit.extract_from (... bad data ...)
I moved ExtractionFailed to the SemanticText module, so now test / unit says:
<:ExtractionFailed> expected to be thrown but <:"SemanticText::ExtractionFailed"> was thrown.
I tried to write assert_throws (: SemanticText :: ExtractionFailed) {...}, but I got a rather confusing message: TypeError: SemanticText is not a class/module
I can get it working by doing the following (although it seems to be a hack):
assert_throws(SemanticText::ExtractionFailed.to_s.to_sym) { unit.extract_from('5 x 2005')}
So what is the right way to say this statement in ruby?
ruby module symbol testunit
daf
source share