Rolling Your Own Assertions in Ruby


class AssertionError < RuntimeError
end

def assert &block
raise AssertionError unless yield
end

assert { 1 > 0 }
=> nil

assert { 5 == 12 }
AssertionError: AssertionError

Leave a comment