Method: Test::Unit::Assertions#assert_not_empty

Defined in:
lib/test/unit/assertions.rb

#assert_not_empty(object, message = nil) ⇒ Object

Passes if object is not empty.

Example:

assert_not_empty(" ")                      # -> pass
assert_not_empty([nil])                    # -> pass
assert_not_empty({1 => 2})                 # -> pass
assert_not_empty("")                       # -> fail
assert_not_empty([])                       # -> fail
assert_not_empty({})                       # -> fail


1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
# File 'lib/test/unit/assertions.rb', line 1328

def assert_not_empty(object, message=nil)
  _wrap_assertion do
    assert_respond_to(object, :empty?,
                      "The object must respond to :empty?.")
    full_message = build_message(message,
                                 "<?> expected to not be empty.",
                                 object)
    assert_block(full_message) do
      not object.empty?
    end
  end
end