DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Rails Assert_includes

07.27.2009
| 3605 views |
  • submit to reddit
        Seems like this was once a valid assertion, but no longer. If you want to use assert_includes in your rails unit tests, paste the following in test_helper.rb
  # Why isn't this in rails?
  def assert_includes(elem, array, message = nil)
    message = build_message message, '<?> is not found in <?>.', elem, array
    assert_block message do
      array.include? elem
    end
  end