Created
March 13, 2009 19:43
-
-
Save lifo/78731 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
module AssertionExtensions | |
def method_missing(method_id, *arguments, &block) | |
return super unless method_id.to_s =~ /^assert_(not_)?(.*)$/ | |
method = "#{$2}?" | |
object = arguments.first | |
if $1 | |
arguments.each do |object| | |
assert ! object.send(method), "#{method} is not false for #{object}" | |
end | |
else | |
arguments.each do |object| | |
assert object.send(method), "#{method} is not true for #{object}" | |
end | |
end | |
end | |
end | |
class ActiveSupport::TestCase | |
include AssertionExtensions | |
end |
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
class PersonTest < ActiveSupport::TestCase | |
def test_is_admin | |
assert_admin people(:admin), people(:superuser) | |
assert_not_admin people(:foo), people(:guest) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment