Sha256: daf118a7fc9b5ff66adbd6f324f137ae9227496c24bc8bb5ee1cad0b402d95eb
Contents?: true
Size: 757 Bytes
Versions: 2
Compression:
Stored size: 757 Bytes
Contents
require 'test/unit/assertions' module Test::Unit #:nodoc:# module Assertions #:nodoc:# # A better 'assert_raise'. +patterns+ can be one or more Regexps, or a literal String that # must match the entire error message. def assert_error(err_type,*patterns,&block) assert_not_nil block, "assert_error requires a block" assert((err_type and err_type.kind_of?(Class)), "First argument to assert_error has to be an error type") err = assert_raise(err_type) do block.call end patterns.each do |pattern| case pattern when Regexp assert_match(pattern, err.message) else assert_equal pattern, err.message end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ceedling-0.29.1 | vendor/hardmock/lib/assert_error.rb |
ceedling-0.29.0 | vendor/hardmock/lib/assert_error.rb |