Sha256: e0af0613cc500b35f382acefd88bb8468103c64d5deb669de95e2879019e1006

Contents?: true

Size: 1019 Bytes

Versions: 1

Compression:

Stored size: 1019 Bytes

Contents

require 'lib/public_suffix_list'

describe PublicSuffixList do

  before do
    @public_suffix_list = PublicSuffixList.new(:effective_tld_names_url => "spec/test.dat")
  end

  it "should calculate tld and cdn correctly" do
    @public_suffix_list.cdn("foo.bar.com").should == "bar.com"
    @public_suffix_list.tld("foo.bar.com").should == "com"
    @public_suffix_list.cdn("foobar.com").should == "foobar.com"
    @public_suffix_list.tld("foobar.com").should == "com"
  end

  it "should not assume the root name is a top level domain" do
    @public_suffix_list.tld("com").should == "com"
    @public_suffix_list.tld("bar.foo").should == "bar.foo"
    @public_suffix_list.tld("baz.foo").should == "baz.foo"
    @public_suffix_list.tld("qux.foo").should == ""
    @public_suffix_list.tld("foo").should == ""
  end

  it "should handle edge cases correctly" do
    @public_suffix_list.split("").should == ["", "", ""]
    @public_suffix_list.cdn("").should == ""
    @public_suffix_list.tld("").should == ""
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
public-suffix-list-0.0.3 spec/public_suffix_list.spec