This method is deprecated or moved on the latest stable version.
The last existing version (v1.2.6) is shown here.
assert(context = nil, &condition)
public
This asserts that the block evaluates to true. If it doesn’t evaluate
to true a breakpoint will
automatically be created at that execution point.
You can disable assert checking in
production code by setting Breakpoint.optimize_asserts to true. (It will
still be enabled when Ruby is run via the -d argument.)
Note: If you want to use this method from an unit test, you will have to
call it by its full name, Breakpoint.assert.
# File activesupport/lib/active_support/breakpoint.rb, line 240
def assert(context = nil, &condition)
return if Breakpoint.optimize_asserts and not $DEBUG
return if yield
callstack = caller
callstack.slice!(0, 3) if callstack.first["assert"]
file, line, method = *callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/).captures
message = "Assert failed at #{file}:#{line}#{" in `#{method}'" if method}."
if Breakpoint.asserts_cause_exceptions and not $DEBUG then
raise(Breakpoint::FailedAssertError, message)
end
message += " Executing implicit breakpoint."
if context then
return handle_breakpoint(context, message, file, line)
end
Binding.of_caller do |context|
handle_breakpoint(context, message, file, line)
end
end