test/abstract_unit.rb in opal-activesupport-0.3.1 vs test/abstract_unit.rb in opal-activesupport-0.3.2

- old
+ new

@@ -24,23 +24,40 @@ # Thread.abort_on_exception = true # # # Show backtraces for deprecated behavior for quicker cleanup. # ActiveSupport::Deprecation.debug = true +# To help opal-minitest print errors. +Encoding.default_external = Encoding::UTF_8 + require 'minitest/autorun' require 'empty_bool' require 'active_support' class ActiveSupport::TestCase < Minitest::Test def self.test name, &block define_method "test_#{name.gsub(/[\W-]+/, '_')}", &block end - def assert_raise error, &block + def assert_raise error_class, &block block.call - assert false, "Expected to see #{error.inspect}, but no exception was raised" - rescue error - # noop + assert false, "Expected to see #{error_class.inspect}, but no exception was raised" + rescue error_class => error + error rescue => actual_error - assert false, "Expected to see #{error.inspect}, but got #{actual_error.inspect}" + assert false, "Expected to see #{error_class.inspect}, but got #{actual_error.inspect}" + end + + def assert_nothing_raised(&block) + block.call + rescue => e + assert false, "Expected no error, but got #{e.inspect}" + end + + def assert_not_empty(object) + assert !object.empty?, "Expected not empty object, but got: #{object.inspect}" + end + + def assert_not_same(obj1, obj2) + assert !obj1.equal?(obj2), "Excepted #{obj1.inspect} and #{obj2.inspect} to be different objects" end end