Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Ruby Testing Assertions

DZone's Guide to

Ruby Testing Assertions

·
Free Resource

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:

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}