Skip to content

Instantly share code, notes, and snippets.

@south37
Last active December 9, 2017 08:10
Show Gist options
  • Save south37/38a20ad6dde2e0589be23745ab469020 to your computer and use it in GitHub Desktop.
Save south37/38a20ad6dde2e0589be23745ab469020 to your computer and use it in GitHub Desktop.
## Definition of assert!
class AssertError < RuntimeError; end
def assert!(&block)
raise AssertError.new("Assertion failed!") if !block.call
rescue AssertError => e
print e
code = <<-CODE
require 'pry'
binding.pry
CODE
eval(code, block.binding)
raise e
end
## example
assert!{ a == 3 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment