module Test::Unit::Assertions

Public Instance Methods

assert_raises(*exp, &b) click to toggle source
# File lib/core_assertions.rb, line 43
def assert_raises(*exp, &b)
  raise NoMethodError, "use assert_raise", caller
end
message(msg = nil, ending = nil, &default) click to toggle source

Returns a proc that will output msg along with the default message.

# File lib/core_assertions.rb, line 58
def message msg = nil, ending = nil, &default
  proc {
    ending ||= (ending_pattern = /(?<!\.)\z/; ".")
    ending_pattern ||= /(?<!#{Regexp.quote(ending)})\z/
    msg = msg.call if Proc === msg
    ary = [msg, (default.call if default)].compact.reject(&:empty?)
    ary.map! {|str| str.to_s.sub(ending_pattern, ending) }
    begin
      ary.join("\n")
    rescue Encoding::CompatibilityError
      ary.map(&:b).join("\n")
    end
  }
end