Sha256: a128b57cffc9432d7aeb562ac0185d3e0189c7c0be4611ceafeb531cae787ea3

Contents?: true

Size: 1.27 KB

Versions: 32

Compression:

Stored size: 1.27 KB

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}'"
      assert PublicSuffix.valid?(name)
    end
  end

  InvalidCases = [
    ["nic.ke",                  PublicSuffix::DomainNotAllowed],
    ["http://www.google.com",   PublicSuffix::DomainInvalid],
    [nil,                       PublicSuffix::DomainInvalid],
    ["",                        PublicSuffix::DomainInvalid],
    ["  ",                      PublicSuffix::DomainInvalid],
  ]

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

end

Version data entries

32 entries across 32 versions & 3 rubygems

Version Path
test_track_rails_client-2.0.0 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-1.3.0 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-1.2.0 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-1.1.0 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-1.0.0 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-0.9.20 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-0.9.19 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/public_suffix-1.4.6/test/acceptance_test.rb
test_track_rails_client-0.9.18 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-0.9.17 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-0.9.16 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-0.9.15 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-0.9.14 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-0.9.13 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-0.9.12 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-0.9.11 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-0.9.10 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-0.9.9 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
test_track_rails_client-0.9.8 vendor/gems/publicsuffix-ruby/test/acceptance_test.rb
public_suffix-1.4.6 test/acceptance_test.rb