aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test/unit/assertions.rb
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-23 21:36:05 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-23 21:36:05 +0000
commitabef077ec7bbb60753f49290f90a90bb1b0a39e0 (patch)
tree0f0e178db3ee5899444e4ad485df331db8f079fe /lib/test/unit/assertions.rb
parent7c083f8c1f102ba2ded720567894f03e68227371 (diff)
downloadruby-abef077ec7bbb60753f49290f90a90bb1b0a39e0.tar.gz
Added miniunit 1.3.0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/test/unit/assertions.rb')
-rw-r--r--lib/test/unit/assertions.rb59
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/test/unit/assertions.rb b/lib/test/unit/assertions.rb
new file mode 100644
index 0000000000..6c29b78096
--- /dev/null
+++ b/lib/test/unit/assertions.rb
@@ -0,0 +1,59 @@
+############################################################
+# This file is imported from a different project.
+# DO NOT make modifications in this repo.
+# File a patch instead and assign it to Ryan Davis
+############################################################
+
+require 'mini/test'
+require 'test/unit/deprecate'
+
+module Test; end
+module Test::Unit # patch up bastards that that extend improperly.
+ if defined? Assertions then
+ warn "ARGH! someone defined Test::Unit::Assertions rather than requiring"
+ CRAP_ASSERTIONS = Assertions
+ remove_const :Assertions
+
+ # this will break on junit and rubinius... *sigh*
+ ObjectSpace.each_object(Module) do |offender|
+ offender.send :include, ::Mini::Assertions if offender < CRAP_ASSERTIONS
+ end rescue nil
+
+ Test::Unit::TestCase.send :include, CRAP_ASSERTIONS
+ end
+
+ Assertions = ::Mini::Assertions
+
+ module Assertions
+ def self.included mod
+ mod.send :include, Test::Unit::CRAP_ASSERTIONS
+ end if defined? Test::Unit::CRAP_ASSERTIONS
+ end
+end
+
+module Test::Unit
+ module Assertions # deprecations
+ tu_deprecate :assert_nothing_thrown, :assert_nothing_raised # 2009-06-01
+ tu_deprecate :assert_raise, :assert_raises # 2010-06-01
+ tu_deprecate :assert_not_equal, :refute_equal # 2009-06-01
+ tu_deprecate :assert_no_match, :refute_match # 2009-06-01
+ tu_deprecate :assert_not_nil, :refute_nil # 2009-06-01
+ tu_deprecate :assert_not_same, :refute_same # 2009-06-01
+
+ def assert_nothing_raised _ = :ignored # 2009-06-01
+ self.class.tu_deprecation_warning :assert_nothing_raised
+ self._assertions += 1
+ yield
+ rescue => e
+ raise Mini::Assertion, exception_details(e, "Exception raised:")
+ end
+
+ def build_message(user_message, template_message, *args) # 2009-06-01
+ self.class.tu_deprecation_warning :build_message
+ user_message ||= ''
+ user_message += ' ' unless user_message.empty?
+ msg = template_message.split(/<\?>/).zip(args.map { |o| o.inspect })
+ user_message + msg.join
+ end
+ end
+end