2010-03-23 11:28:17 -04:00
|
|
|
require 'active_support/test_case'
|
|
|
|
|
2009-10-07 20:46:40 -04:00
|
|
|
class ActiveSupport::TestCase
|
|
|
|
def assert_not(assertion)
|
|
|
|
assert !assertion
|
|
|
|
end
|
|
|
|
|
|
|
|
def assert_blank(assertion)
|
|
|
|
assert assertion.blank?
|
|
|
|
end
|
|
|
|
|
|
|
|
def assert_not_blank(assertion)
|
|
|
|
assert !assertion.blank?
|
|
|
|
end
|
|
|
|
alias :assert_present :assert_not_blank
|
|
|
|
|
2011-08-12 12:27:57 -04:00
|
|
|
def assert_email_sent(address = nil, &block)
|
2012-05-15 16:19:21 -04:00
|
|
|
assert_difference('ActionMailer::Base.deliveries.size', &block)
|
2011-08-12 12:27:57 -04:00
|
|
|
if address.present?
|
|
|
|
assert_equal address, ActionMailer::Base.deliveries.last['to'].to_s
|
|
|
|
end
|
2009-10-07 20:46:40 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def assert_email_not_sent(&block)
|
2012-05-15 16:19:21 -04:00
|
|
|
assert_no_difference('ActionMailer::Base.deliveries.size', &block)
|
2009-10-07 20:46:40 -04:00
|
|
|
end
|
2012-02-20 06:54:45 -05:00
|
|
|
|
2012-02-22 13:49:09 -05:00
|
|
|
def assert_same_content(result, expected)
|
|
|
|
assert expected.size == result.size, "the arrays doesn't have the same size"
|
2012-02-20 06:54:45 -05:00
|
|
|
expected.each do |element|
|
2012-02-22 13:49:09 -05:00
|
|
|
assert result.include?(element), "The array doesn't include '#{element}'."
|
2012-02-20 06:54:45 -05:00
|
|
|
end
|
|
|
|
end
|
2012-02-21 07:31:38 -05:00
|
|
|
|
2012-05-15 16:19:21 -04:00
|
|
|
def assert_raise_with_message(exception_klass, message, &block)
|
|
|
|
exception = assert_raise exception_klass, &block
|
|
|
|
assert_equal exception.message, message,
|
|
|
|
"The expected message was #{message} but your exception throwed #{exception.message}"
|
2012-02-21 07:31:38 -05:00
|
|
|
end
|
2009-10-07 20:46:40 -04:00
|
|
|
end
|