aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/testing/assertions.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/testing/assertions.rb')
-rw-r--r--activesupport/lib/active_support/testing/assertions.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb
index c529b92240..33793f0688 100644
--- a/activesupport/lib/active_support/testing/assertions.rb
+++ b/activesupport/lib/active_support/testing/assertions.rb
@@ -1,4 +1,5 @@
require 'active_support/core_ext/array/wrap'
+require 'active_support/core_ext/object/blank'
module ActiveSupport
module Testing
@@ -62,6 +63,20 @@ module ActiveSupport
def assert_no_difference(expression, message = nil, &block)
assert_difference expression, 0, message, &block
end
+
+ # 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"
+ 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"
+ end
end
end
end