Sha256: 00111093050931d3f7b641d1114d9bdfc4c42aab33f7a5ec9ed3f76ddb6e5569
Contents?: true
Size: 1.91 KB
Versions: 11
Compression:
Stored size: 1.91 KB
Contents
require File.join(File.dirname(__FILE__), 'helper') class TestDomains < Minitest::Test WHITELIST = [ "non-us gov", "non-us mil", "US Federal"] DOMAINS = Gman::Parser.file_to_hash(Gman.list_path) def whitelisted?(domain) WHITELIST.each do |group| return true if DOMAINS[group].include? domain end false end should "only contain resolvable domains" do unresolvables = [] Parallel.each(Gman.list, :in_threads => 2) do |entry| next if whitelisted? entry.name resolves = Gman::Parser.domain_resolves?(entry.name) unresolvables.push entry.name unless resolves end assert_equal [], unresolvables end should "not contain any educational domains" do Parallel.each(Gman.list, :in_threads => 2) do |entry| assert_equal false, Swot::is_academic?(entry.name), "#{entry.name} is an academic domain" end end should "not contain any invalid domains" do Parallel.each(Gman.list, :in_threads => 2) do |entry| assert_equal true, PublicSuffix.valid?("foo.#{entry.name}"), "#{entry.name} is not a valid domain" end end should "pass any url on the list" do Parallel.each(Gman.list, :in_threads => 2) do |entry| assert_equal true, Gman.valid?("http://foo.#{entry.name}/bar"), "http://foo.#{entry.name}/bar is not a valid" end end should "pass any email on the list" do Parallel.each(Gman.list, :in_threads => 2) do |entry| assert_equal true, Gman.valid?("foo@bar.#{entry.name}"), "foo@bar.#{entry.name} is not a valid" end end should "pass any domain on the list" do Parallel.each(Gman.list, :in_threads => 2) do |entry| assert_equal true, Gman.valid?("foo.#{entry.name}"), "foo.#{entry.name} is not a valid domain" end end should "identify the coutnry for any domain on the list" do Parallel.each(Gman.list, :in_threads => 2) do |entry| Gman.new("foo.#{entry.name}").country.name end end end
Version data entries
11 entries across 11 versions & 1 rubygems