From fb6b80562041e8d2378cad1b51f8c234fe76fd5e Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 17 Aug 2010 03:29:57 +0200 Subject: code gardening: we have assert_(nil|blank|present), more concise, with better default failure messages - let's use them --- activesupport/lib/active_support/testing/assertions.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb index 8c68f42781..a4e0361a32 100644 --- a/activesupport/lib/active_support/testing/assertions.rb +++ b/activesupport/lib/active_support/testing/assertions.rb @@ -67,15 +67,17 @@ module ActiveSupport # Test if an expression is blank. Passes if object.blank? is true. # # assert_blank [] # => true - def assert_blank(object) - assert object.blank?, "#{object.inspect} is not blank" + def assert_blank(object, message=nil) + message ||= "#{object.inspect} is not blank" + assert object.blank?, message end # Test if an expression is not blank. Passes if object.present? is true. # # assert_present {:data => 'x' } # => true - def assert_present(object) - assert object.present?, "#{object.inspect} is blank" + def assert_present(object, message=nil) + message ||= "#{object.inspect} is blank" + assert object.present?, message end end end -- cgit v1.2.3