diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2021-06-25 18:58:17 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2021-06-25 20:36:12 +0900 |
commit | 7e45e3899d1e3aa87826d7d61f6ebad4f1691e6b (patch) | |
tree | 92f69f88cd2a816ff37fe73c1655c3f52aebf711 | |
parent | 47283d91614ab799dc2347c37885a37f1b91afcb (diff) | |
download | ruby-openssl-ky/use-bundler.tar.gz |
test/openssl/envutil: remove assert_raise_with_messageky/use-bundler
test-unit 3.4.3 added "assert_raise_with_message" to the default
assertion methods set.
-rw-r--r-- | Gemfile | 2 | ||||
-rw-r--r-- | test/openssl/envutil.rb | 52 |
2 files changed, 1 insertions, 53 deletions
@@ -4,5 +4,5 @@ gemspec gem "rake" gem "rake-compiler" -gem "test-unit", "~> 3.0" +gem "test-unit", "~> 3.0", ">= 3.4.3" gem "rdoc" diff --git a/test/openssl/envutil.rb b/test/openssl/envutil.rb index 05d6fe27..1ab36ff3 100644 --- a/test/openssl/envutil.rb +++ b/test/openssl/envutil.rb @@ -282,58 +282,6 @@ eom end values end - - def mu_pp(obj) #:nodoc: - obj.pretty_inspect.chomp - end - - # :call-seq: - # assert_raise_with_message(exception, expected, msg = nil, &block) - # - #Tests if the given block raises an exception with the expected - #message. - # - # assert_raise_with_message(RuntimeError, "foo") do - # nil #Fails, no Exceptions are raised - # end - # - # assert_raise_with_message(RuntimeError, "foo") do - # raise ArgumentError, "foo" #Fails, different Exception is raised - # end - # - # assert_raise_with_message(RuntimeError, "foo") do - # raise "bar" #Fails, RuntimeError is raised but the message differs - # end - # - # assert_raise_with_message(RuntimeError, "foo") do - # raise "foo" #Raises RuntimeError with the message, so assertion succeeds - # end - def assert_raise_with_message(exception, expected, msg = nil, &block) - case expected - when String - assert = :assert_equal - when Regexp - assert = :assert_match - else - raise TypeError, "Expected #{expected.inspect} to be a kind of String or Regexp, not #{expected.class}" - end - - ex = m = nil - ex = assert_raise(exception, msg || "Exception(#{exception}) with message matches to #{expected.inspect}") do - yield - end - m = ex.message - msg = message(msg, "") {"Expected Exception(#{exception}) was raised, but the message doesn't match"} - - if assert == :assert_equal - assert_equal(expected, m, msg) - else - msg = message(msg) { "Expected #{mu_pp expected} to match #{mu_pp m}" } - assert expected =~ m, msg - block.binding.eval("proc{|_|$~=_}").call($~) - end - ex - end end end end |