lib/active_support/testing/assertions.rb in activesupport-3.0.0.beta vs lib/active_support/testing/assertions.rb in activesupport-3.0.0.beta2

- old
+ new

@@ -1,6 +1,7 @@ require 'active_support/core_ext/array/wrap' +require 'active_support/core_ext/object/blank' module ActiveSupport module Testing module Assertions # Test numeric difference between the return value of an expression as a result of what is evaluated @@ -59,9 +60,23 @@ # assert_no_difference 'Article.count', "An Article should not be destroyed" do # post :create, :article => invalid_attributes # end 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