Last active
December 9, 2017 08:10
-
-
Save south37/38a20ad6dde2e0589be23745ab469020 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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