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:

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

{{ parent.tldr }}

{{ parent.urlSource.name }}