spec/postrank-uri_spec.rb in postrank-uri-1.0.9 vs spec/postrank-uri_spec.rb in postrank-uri-1.0.10

- old
+ new

@@ -130,10 +130,16 @@ c('http://twitter.com/#!/a/statuses/1').should == 'http://twitter.com/a/statuses/1' c('http://nontwitter.com/#!/a/statuses/1').should == 'http://nontwitter.com/#!/a/statuses/1' end end + context "tumblr" do + it "should strip slug" do + c('http://test.tumblr.com/post/4533459403/some-text').should == 'http://test.tumblr.com/post/4533459403/' + end + end + context "embedded links" do it "should extract embedded redirects from Google News" do u = c('http://news.google.com/news/url?sa=t&fd=R&&url=http://www.ctv.ca/CTVNews/Politics/20110111/') u.should == 'http://www.ctv.ca/CTVNews/Politics/20110111' end @@ -165,10 +171,12 @@ c('igvita.com/a/..?id=1&utm_source=a&awesm=b#c').should == 'http://igvita.com/?id=1' c('igvita.com?id=<>').should == 'http://igvita.com/?id=%3C%3E' c('igvita.com?id="').should == 'http://igvita.com/?id=%22' + + c('test.tumblr.com/post/23223/text-stub').should == 'http://test.tumblr.com/post/23223' end it "should clean host specific parameters" do YAML.load_file('spec/c18n_hosts.yml').each do |orig, clean| c(orig).should == clean @@ -191,12 +199,12 @@ end it "should not clean the URI if requested" do hash = '55fae8910d312b7878a3201ed653b881' - h('http://everburning.com/feed/post/1', :skip_clean => true).should == hash - h('everburning.com/feed/post/1', :skip_clean => true).should_not == hash + h('http://everburning.com/feed/post/1', :clean => false).should == hash + h('everburning.com/feed/post/1', :clean => false).should_not == hash end end context "extract" do def e(text) @@ -271,32 +279,33 @@ i.first.should == 'http://igvita.com/stuff' i.last.should == 'link to stuff' end end - context 'domain extraction' do - url_list = {"http://alex.pages.example.com" => "example.com", - "alex.pages.example.com" => "example.com", - "http://example.com/2011/04/01/blah" => "example.com", - "http://example.com" => "example.com", - "example.com" => "example.com", - "ExampLe.com" => "example.com", - "ExampLe.com:3000" => "example.com", - "http://alex.pages.example.COM" => "example.com", - "http://www.example.ag.it/2011/04/01/blah" => "example.ag.it", - "ftp://www.example.com/2011/04/01/blah" => nil, - "http://com" => nil, - "http://alex.pages.examplecom" => nil, - "example" => nil, - "http://127.0.0.1" => nil, - "localhost" => nil - } + context "domain extraction" do + url_list = { + "http://alex.pages.example.com" => "example.com", + "alex.pages.example.com" => "example.com", + "http://example.com/2011/04/01/blah" => "example.com", + "http://example.com" => "example.com", + "example.com" => "example.com", + "ExampLe.com" => "example.com", + "ExampLe.com:3000" => "example.com", + "http://alex.pages.example.COM" => "example.com", + "http://www.example.ag.it/2011/04/01/blah" => "example.ag.it", + "ftp://www.example.com/2011/04/01/blah" => nil, + "http://com" => nil, + "http://alex.pages.examplecom" => nil, + "example" => nil, + "http://127.0.0.1" => nil, + "localhost" => nil + } - url_list.each_pair do |url, expected_result| - it "should extract #{expected_result.inspect} from #{url}" do - u = PostRank::URI.clean(url, :raw => true) - u.domain.should == expected_result - end - end + url_list.each_pair do |url, expected_result| + it "should extract #{expected_result.inspect} from #{url}" do + u = PostRank::URI.clean(url, :raw => true) + u.domain.should == expected_result + end + end end end end