Using assert_raise

When Im writing tests and I do:

assert_raise RuntimeError, raise(“raising”)

Then I run the test is says the test failed and I have 1 error:

RuntimeError: hey

Should assert_raise catch that error and say the test passed?

Thanks for your time and help.

Ben J. wrote:

When Im writing tests and I do:

assert_raise RuntimeError, raise(“raising”)

Then I run the test is says the test failed and I have 1 error:

RuntimeError: hey

Should assert_raise catch that error and say the test passed?

Thanks for your time and help.

I figured it out, you need to pass a block, like:

assert_raise(RuntimeError) { raise(“raising”) }

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs