Eliasz Łukasz
Eliasz Łukasz

Reputation: 548

How to check for RuntimeError with Test/Unit

In my program, I use raise "text" to prevent creating an object when parameters are wrong.

How can I check this in Test/Unit?

assert_ ? (MyObject.new(wrong,parameter))

How can I check that my object was not created?

Upvotes: 0

Views: 71

Answers (1)

Eliasz Łukasz
Eliasz Łukasz

Reputation: 548

def test_illegal
  assert_raise( RuntimeError ) { MyObject.new('a') }
end

Upvotes: 2

Related Questions