Sha256: 999aed5d9e86af134c9a6345695008111446767f2e5a3efd205bc53c560f42ff
Contents?: true
Size: 1.38 KB
Versions: 5
Compression:
Stored size: 1.38 KB
Contents
require "test_helper" require "public_suffix" # This test runs against the current PSL file and ensures # the definitions satisfies the test suite. class PslTest < Minitest::Unit::TestCase ROOT = File.expand_path("../../", __FILE__) # rubocop:disable Lint/Eval def self.tests File.readlines(File.join(ROOT, "test/tests.txt")).map do |line| line = line.strip next if line.empty? next if line.start_with?("//") input, output = line.split(", ") # handle the case of eval("null"), it must be eval("nil") input = "nil" if input == "null" output = "nil" if output == "null" input = eval(input) output = eval(output) [input, output] end end # rubocop:enable def test_valid # Parse the PSL and run the tests data = File.read(PublicSuffix::List::DEFAULT_LIST_PATH) PublicSuffix::List.default = PublicSuffix::List.parse(data) failures = [] self.class.tests.each do |input, output| # Punycode domains are not supported ATM next if input =~ /xn\-\-/ domain = PublicSuffix.domain(input) rescue nil failures << [input, output, domain] if output != domain end message = "The following #{failures.size} tests fail:\n" failures.each { |i, o, d| message += "Expected %s to be %s, got %s\n" % [i.inspect, o.inspect, d.inspect] } assert_equal 0, failures.size, message end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
public_suffix-2.0.4 | test/psl_test.rb |
public_suffix-2.0.3 | test/psl_test.rb |
public_suffix-2.0.2 | test/psl_test.rb |
public_suffix-2.0.1 | test/psl_test.rb |
public_suffix-2.0.0 | test/psl_test.rb |