Over a million developers have joined DZone.

Ruby Testing Assertions

·

assert_equal(1, 1)
assert_not_equal(1, 0)

assert_match(/test/, "test")
assert_no_match(/test/, "dfjlas")

assert(true) # nil | false fails test

assert_in_delta(1.3, 1.7, 0.3, "not with range") # used to identify if decimals are with a certain range of each other

flunk("force test to fail") # forces test to fail
Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}