Skip to content

Instantly share code, notes, and snippets.

@dbrady
Created January 21, 2009 19:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dbrady/50122 to your computer and use it in GitHub Desktop.
# 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