TypeError is appropriate here

This commit is contained in:
Jack Nagel 2013-05-06 16:08:49 -05:00
parent 666b48e391
commit 894a6c9776
2 changed files with 10 additions and 2 deletions

View File

@ -59,7 +59,7 @@ class DependencyCollector
when Class
parse_class_spec(spec, tag)
else
raise "Unsupported type #{spec.class} for #{spec}"
raise TypeError, "Unsupported type #{spec.class} for #{spec}"
end
end
@ -99,7 +99,7 @@ class DependencyCollector
if spec < Requirement
spec.new(tag)
else
raise "#{spec} is not a Requirement subclass"
raise TypeError, "#{spec} is not a Requirement subclass"
end
end

View File

@ -110,4 +110,12 @@ class DependencyCollectorTests < Test::Unit::TestCase
MacOS.stubs(:version).returns(MacOS::Version.new(10.7))
assert_equal X11Dependency::Proxy.new(:libpng), @d.build(:libpng)
end
def test_raises_typeerror_for_unknown_classes
assert_raises(TypeError) { @d.add(Class.new) }
end
def test_raises_typeerror_for_unknown_types
assert_raises(TypeError) { @d.add(Object.new) }
end
end