Created
January 21, 2009 19:13
-
-
Save dbrady/50122 to your computer and use it in GitHub Desktop.
This file contains 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
# What is existence? | |
class Be | |
def initialize | |
end | |
def matches?(actual) | |
defined? actual | |
end | |
def failure_message | |
"expected the expression to exist, but it didn't" | |
end | |
def negative_failure_message | |
"expected the expression to not exist, but it did" | |
end | |
end | |
# Now you can say things like | |
# | |
# Zen.should be | |
# | |
def be | |
Be.new | |
end | |
# Note that if Zen does not exist, you won't get a failure message, | |
# you'll get an undefined constant exception. A pity. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment