module RubyUnit::Assertions::Collections

Public Instance Methods

assertEmpty(object, message = nil) click to toggle source

Assert that a value is empty

object

The object to check

message

The message provided to be reported for a failure

assertEmpty [1, 2], 'Not empty'  # => fail
# File lib/RubyUnit/Assertions/Collections.rb, line 64
def assertEmpty object, message = nil
  __assert_empty ASSERT_EMPTY_ERROR, object, message do
    object.empty?
  end
end
assertInclude(collection, value, message = nil) click to toggle source

Assert that a collection includes a specified value

collection

The collection to check

value

The value the object should contain

message

The message provided to be reported for a failure

assertInclude [1, 2], 'not in', 'It does not, so... no'  # => fail
# File lib/RubyUnit/Assertions/Collections.rb, line 24
def assertInclude collection, value, message = nil
  __assert_include ASSERT_INCLUDE_ERROR, collection, value, message do
    collection.include? value
  end
end
assertNotEmpty(object, message = nil) click to toggle source

Assert that a value is not empty

object

The object to check

message

The message provided to be reported for a failure

assertNotInclude [1, 2, 3], 2, 'It does, so close'  # => fail
# File lib/RubyUnit/Assertions/Collections.rb, line 83
def assertNotEmpty object, message = nil
  __assert_empty ASSERT_NOT_EMPTY_ERROR, object, message do
    not object.empty?
  end
end
assertNotInclude(collection, reject, message = nil) click to toggle source

Assert that a collection does not include a specified value

collection

The collection to check

reject

The value the object should not contain

message

The message provided to be reported for a failure

assertNotInclude [1, 2, 3], 2, 'It does, so close'  # => fail
# File lib/RubyUnit/Assertions/Collections.rb, line 45
def assertNotInclude collection, reject, message = nil
  __assert_include ASSERT_NOT_INCLUDE_ERROR, collection, reject, message do
    not collection.include? reject
  end
end