Skip to content

Instantly share code, notes, and snippets.

@niclasnilsson
Created May 18, 2015 18:45
Show Gist options
  • Save niclasnilsson/89f9a8c28caae0c1634a to your computer and use it in GitHub Desktop.
Save niclasnilsson/89f9a8c28caae0c1634a to your computer and use it in GitHub Desktop.
require 'clean_assert'
def add_drinking_person(name, age)
assert / "name != nil" / "not name.empty?" / "age >= 21"
puts "Adding '#{name}' of age #{age} to the list of drinkers"
# And some code to do it...
end
add_drinking_person("Niclas", 17)
# Gives:
# RuntimeError: Assertion 'age >= 21' not satisfied in main#add_drinking_person
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment