module RubyUnit::Assertions::Methods

Public Instance Methods

assertClassMethod(klass, class_method, message = nil) click to toggle source

Assert that an Class has defined the specified class method.

klass

The object to check for class_method

method

The method to check

message

The message provided to be reported for a failure

assertClassMethod String, :integer?, 'Nope' # => fail
# File lib/RubyUnit/Assertions/Methods.rb, line 138
def assertClassMethod klass, class_method, message = nil
  assertInclude klass.singleton_methods, class_method, message
end
assertInstanceMethod(klass, instance_method, message = nil) click to toggle source

Assert that an object has defined the specified instance method.

klass

The object to check for instance_method

method

The method to check

message

The message provided to be reported for a failure

assertInstanceMethod String, :integer?, 'Nope' # => fail
# File lib/RubyUnit/Assertions/Methods.rb, line 100
def assertInstanceMethod klass, instance_method, message = nil
  assertInclude klass.instance_methods, instance_method, message
end
assertMethod(klass, method, message = nil) click to toggle source

Assert that an object has defined the specified method.

klass

The object to check for method

method

The method to check

message

The message provided to be reported for a failure

assertMethod String, :integer?, 'Nope' # => fail
# File lib/RubyUnit/Assertions/Methods.rb, line 62
def assertMethod klass, method, message = nil
  assertInclude klass.methods, method, message
end
assertNotClassMethod(klass, not_class_method, message = nil) click to toggle source

Assert that an Class has not defined the specified class method.

klass

The object to check for not_class_method

method

The method to check

message

The message provided to be reported for a failure

assertNotClassMethod String, :new, 'Nope' # => fail
# File lib/RubyUnit/Assertions/Methods.rb, line 157
def assertNotClassMethod klass, not_class_method, message = nil
  assertNotInclude klass.singleton_methods, not_class_method, message
end
assertNotInstanceMethod(klass, not_instance_method, message = nil) click to toggle source

Assert that an object has not defined the specified instance method.

klass

The object to check for not_instance_method

method

The method to check

message

The message provided to be reported for a failure

assertNotInstanceMethod Integer, :integer?, 'Nope' # => fail
# File lib/RubyUnit/Assertions/Methods.rb, line 119
def assertNotInstanceMethod klass, not_instance_method, message = nil
  assertNotInclude klass.instance_methods, not_instance_method, message
end
assertNotMethod(klass, not_method, message = nil) click to toggle source

Assert that an object has not defined the specified method.

klass

The object to check for method

method

The method to check

message

The message provided to be reported for a failure

assertNotMethod Integer, :integer?, 'Nope' # => fail
# File lib/RubyUnit/Assertions/Methods.rb, line 81
def assertNotMethod klass, not_method, message = nil
  assertNotInclude klass.methods, not_method, message
end
assertNotRespondTo(object, method, message = nil) click to toggle source

Assert that an object does not respond to a particular method

object

The object to check

method

The method to assert on the object

message

The message provided to be reported for a failure

assertNotRespondTo 25, :integer?, 'It does, so close'  # => fail
# File lib/RubyUnit/Assertions/Methods.rb, line 43
def assertNotRespondTo object, method, message = nil
  __assert (object.respond_to? method), ASSERT_NOT_RESPOND_TO_ERROR, message, {:object=>object, :method=>method}
end
assertRespondTo(object, method, message = nil) click to toggle source

Assert that an object responds to particular method

object

The object to check

method

The method to assert on the object

message

The message provided to be reported for a failure

assertRespondTo /^Regexp/, :length, 'It does not, so... no'  # => fail
# File lib/RubyUnit/Assertions/Methods.rb, line 24
def assertRespondTo object, method, message = nil
  __assert (object.respond_to? method), ASSERT_RESPOND_TO_ERROR, message, {:object=>object, :method=>method}
end