Sha256: 79cb093493b417a98d4cac580f9c1aae7efcbf4b152b2bb09db0066296fd7b57

Contents?: true

Size: 912 Bytes

Versions: 43

Compression:

Stored size: 912 Bytes

Contents

#!/usr/bin/env ruby

$:.unshift(File.join(File.dirname(__FILE__), '..'))

require 'test/unit'
require 'rex/exceptions'

module Rex
module Exceptions

class UnitTest < Test::Unit::TestCase

	def test_exceptions
		Rex.constants.each { |const|
			mod = Rex.const_get(const)

			if ((mod.kind_of?(Class) == false) ||
			    (mod.ancestors.include?(Rex::Exception) == false))
				next
			end

			begin
				raise mod.new
			rescue ::ArgumentError
			rescue mod => detail
				assert_respond_to(detail, 'to_s', "#{mod} does not implement to_s")
				assert_not_nil(detail.to_s, "invalid to_s")
			end
		}

		# Test communication error detail strings
		begin
			raise ConnectionRefused.new('127.0.0.1', 4444)
		rescue HostCommunicationError => detail
			assert_match(/^The connection(.*)\(127.0.0.1:4444\)/, detail.to_s)
			assert_equal('127.0.0.1', detail.host)
			assert_equal(4444, detail.port)
		end
	end

end

end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/exceptions.rb.ut.rb
librex-0.0.63 lib/rex/exceptions.rb.ut.rb
librex-0.0.54 lib/rex/exceptions.rb.ut.rb
librex-0.0.53 lib/rex/exceptions.rb.ut.rb
librex-0.0.52 lib/rex/exceptions.rb.ut.rb
librex-0.0.51 lib/rex/exceptions.rb.ut.rb
librex-0.0.50 lib/rex/exceptions.rb.ut.rb
librex-0.0.49 lib/rex/exceptions.rb.ut.rb
librex-0.0.48 lib/rex/exceptions.rb.ut.rb
librex-0.0.47 lib/rex/exceptions.rb.ut.rb
librex-0.0.46 lib/rex/exceptions.rb.ut.rb
librex-0.0.44 lib/rex/exceptions.rb.ut.rb
librex-0.0.43 lib/rex/exceptions.rb.ut.rb
librex-0.0.42 lib/rex/exceptions.rb.ut.rb
librex-0.0.41 lib/rex/exceptions.rb.ut.rb
librex-0.0.40 lib/rex/exceptions.rb.ut.rb
librex-0.0.39 lib/rex/exceptions.rb.ut.rb
librex-0.0.38 lib/rex/exceptions.rb.ut.rb
librex-0.0.37 lib/rex/exceptions.rb.ut.rb
librex-0.0.36 lib/rex/exceptions.rb.ut.rb