test/test_gman.rb in gman-0.1.0 vs test/test_gman.rb in gman-0.2.0

- old
+ new

@@ -20,10 +20,11 @@ "foo@k12.champaign.il.us", "foo@kii.gov.by", "foo", "", nil, + " ", ] class TestGman < Test::Unit::TestCase should "recognize government email addresses and domains" do @@ -85,6 +86,23 @@ Gman.list.each do |entry| assert_equal true, Gman.valid?("foo.#{entry.name}"), "foo.#{entry.name} is not a valid domain" end end + should "not err out on invalid domains" do + assert_equal false, Gman.valid?("foo@act.gov.au") + assert_equal "act.gov.au", Gman.get_domain("foo@act.gov.au") + assert_equal nil, Gman.domain_parts("foo@act.gov.au") + end + + should "return public suffix domain" do + assert_equal PublicSuffix::Domain, Gman.domain_parts("whitehouse.gov").class + assert_equal NilClass, Gman.domain_parts("foo.bar").class + end + + should "parse domain parts" do + assert_equal "gov", Gman.domain_parts("foo@bar.gov").tld + assert_equal "bar", Gman.domain_parts("foo.bar.gov").sld + assert_equal "bar", Gman.domain_parts("https://foo.bar.gov").sld + assert_equal "bar.gov", Gman.domain_parts("foo@bar.gov").domain + end end