Skip to content

Instantly share code, notes, and snippets.

@dbrady
Created Jan 21, 2009
Embed
What would you like to do?
# 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