Ensure args are similar

assert_similar  arg1 (anything), arg2 (anything)

Raises an exception if both arguments aren’t similar.

Currently similarity is only defined for numbers - all other types are compared for equality with assert_equal.

Useful for testing in cases where floating point imprecision stops you from being able to use assert_equal.

Introduced in v3.0

Examples

# Example 1


assert_similar 1, 1



# Simple assertions
#=> True



# Example 2


assert_similar(4.9999999999, 5.0)



# Handles floating point imprecision
#=> True