Sha256: 69ad3034c1c2082d5814b9ef95be7eb4d3c15ed8f4175ec5e2755fee6456eda3

Contents?: true

Size: 734 Bytes

Versions: 41

Compression:

Stored size: 734 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

41 entries across 38 versions & 3 rubygems

Version Path
ceedling-0.31.1 vendor/hardmock/lib/assert_error.rb
ceedling-0.31.0 vendor/hardmock/lib/assert_error.rb
ceedling-0.30.0 vendor/hardmock/lib/assert_error.rb
ceedling-0.28.3 vendor/hardmock/lib/assert_error.rb
ceedling-0.28.2 vendor/hardmock/lib/assert_error.rb
ceedling-0.28.1 vendor/hardmock/lib/assert_error.rb
ceedling-0.27.0 vendor/hardmock/lib/assert_error.rb
ceedling-0.25.0 vendor/hardmock/lib/assert_error.rb
ceedling-0.24.0 vendor/hardmock/lib/assert_error.rb
ceedling-0.22.0 vendor/hardmock/lib/assert_error.rb
ceedling-0.21.0 vendor/hardmock/lib/assert_error.rb
ceedling-0.20.3 vendor/hardmock/lib/assert_error.rb
ceedling-0.20.2 vendor/hardmock/lib/assert_error.rb
ceedling-0.19.0 vendor/hardmock/lib/assert_error.rb
ceedling-0.18.0 vendor/hardmock/lib/assert_error.rb
ceedling-0.17.0 vendor/hardmock/lib/assert_error.rb
ceedling-0.16.0 vendor/hardmock/lib/assert_error.rb
ceedling-0.15.6 vendor/hardmock/lib/assert_error.rb
ceedling-0.15.5 vendor/hardmock/lib/assert_error.rb
ceedling-0.15.4 vendor/hardmock/lib/assert_error.rb