Sha256: 01878965f12369c5f70587890575f54fdb072b7185c976311d5db739bfba6df9

Contents?: true

Size: 971 Bytes

Versions: 5

Compression:

Stored size: 971 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 = PublicSuffixService.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.do" => PublicSuffixService::DomainNotAllowed,
  }

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

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
public_suffix_service-0.8.2 test/acceptance_test.rb
public_suffix_service-0.8.1 test/acceptance_test.rb
public_suffix_service-0.8.0 test/acceptance_test.rb
public_suffix_service-0.7.0 test/acceptance_test.rb
public_suffix_service-0.6.0 test/acceptance_test.rb