DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Ruby Testing Assertions

  • submit to reddit
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