Skip to content

Instantly share code, notes, and snippets.

@joshmcarthur
Forked from anonymous/assert.rb
Last active December 26, 2015 09:39
Show Gist options
  • Save joshmcarthur/7130572 to your computer and use it in GitHub Desktop.
Save joshmcarthur/7130572 to your computer and use it in GitHub Desktop.
module Assert
class AssertFailedException < Exception
end
def assert!(object, method, expected_value)
result = object.send(method)
if result != expected_value
raise new Assert::AssertFailedException("#{object} expected #{method} to be #{expected_value} but was #{result}"
end
end
end
Object.send(:include, Assert)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment