Sha256: ab98aa38207f98dd22914874fb7ad451dbc7e3e5e11dfe8eb57d7b5a06bca3fd

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

require 'public_suffix_list'

describe PublicSuffixList do

  it "should match * if no rules match" do
    public_suffix_list = PublicSuffixList.new(:url => "spec/test.dat")
    public_suffix_list.cache_file.should be nil
    public_suffix_list.split("www.home.foobar").should == ["www", "home", "foobar"]
    public_suffix_list.cdn("www.home.foobar").should == "home.foobar"
    public_suffix_list.tld("www.home.foobar").should == "foobar"
  end

  it "should calculate tld and cdn correctly" do
    public_suffix_list = PublicSuffixList.new(:url => "spec/test.dat")
    public_suffix_list.cache_file.should be nil
    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 = PublicSuffixList.new(:url => "spec/test.dat")
    public_suffix_list.cache_file.should be nil
    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 = PublicSuffixList.new(:url => "spec/test.dat")
    public_suffix_list.cache_file.should be nil
    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.2.0 spec/public_suffix_list_spec.rb