Sha256: b7aa38728387b19450720a1ae2bc4db3316c8da4e4b0a0a6937a209b385a753e

Contents?: true

Size: 950 Bytes

Versions: 3

Compression:

Stored size: 950 Bytes

Contents

require 'test_helper'

class AcceptanceTest < Test::Unit::TestCase

  ValidCases = {
    "google.com" => [nil, "google", "com"],
    "foo.google.com" => ["foo", "google", "com"],

    "verybritish.co.uk" => [nil, "verybritish", "co.uk"],
    "foo.verybritish.co.uk" => ["foo", "verybritish", "co.uk"],

    "parliament.uk" => [nil, "parliament", "uk"],
    "foo.parliament.uk" => ["foo", "parliament", "uk"],
  }

  def test_valid
    ValidCases.each do |name, results|
      domain = PublicSuffix.parse(name)
      trd, sld, tld = results
      assert_equal tld, domain.tld, "Invalid tld for '#{name}'"
      assert_equal sld, domain.sld, "Invalid sld for '#{name}'"
      assert_equal trd, domain.trd, "Invalid trd for '#{name}'"
    end
  end

  InvalidCases = {
    "nic.ke" => PublicSuffix::DomainNotAllowed,
  }

  def test_invalid
    InvalidCases.each do |name, error|
      assert_raise(error) { PublicSuffix.parse(name) }
    end
  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
public_suffix_service-0.9.1 test/acceptance_test.rb
public_suffix-1.0.0 test/acceptance_test.rb
public_suffix-1.0.0.rc1 test/acceptance_test.rb