Lalit (owner)

Fork Of

Revisions

  • 099bcf lifo Fri Mar 13 13:13:59 -0700 2009
  • d0e042 Fri Mar 13 12:43:28 -0700 2009
gist: 78924 Download_button fork
public
Public Clone URL: git://gist.github.com/78924.git
Embed All Files: show embed
assertion_extensions.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
person_test.rb #
1
2
3
4
5
6
class PersonTest < ActiveSupport::TestCase
  def test_is_admin
    assert_admin people(:admin), people(:superuser)
    assert_not_admin people(:foo), people(:guest)
  end
end