spec/postrank-uri_spec.rb in postrank-uri-1.0.7 vs spec/postrank-uri_spec.rb in postrank-uri-1.0.8

- old
+ new

@@ -84,10 +84,20 @@ it "should downcase hostname" do n('IGVITA.COM').should == igvita n('IGVITA.COM/ABC').should == (igvita + "ABC") end + it "should remove trailing slash on paths" do + n('http://igvita.com/').should == 'http://igvita.com/' + + n('http://igvita.com/a').should == 'http://igvita.com/a' + n('http://igvita.com/a/').should == 'http://igvita.com/a' + + n('http://igvita.com/a/b').should == 'http://igvita.com/a/b' + n('http://igvita.com/a/b/').should == 'http://igvita.com/a/b' + end + end context "canonicalization" do def c(uri) PostRank::URI.c18n(uri).to_s @@ -123,21 +133,21 @@ 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/' + u.should == 'http://www.ctv.ca/CTVNews/Politics/20110111' end it "should extract embedded redirects from xfruits.com" do u = c('http://xfruits.com/MrGroar/?url=http%3A%2F%2Faap.lesroyaumes.com%2Fdepeches%2Fdepeche351820908.html') u.should == 'http://aap.lesroyaumes.com/depeches/depeche351820908.html' end it "should extract embedded redirects from MySpace" do u = c('http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fghanaian-chronicle.com%2Fnews%2Fother-news%2Fcanadian-high-commissioner-urges-media%2F&t=Canadian%20High%20Commissioner%20urges%20media') - u.should == 'http://ghanaian-chronicle.com/news/other-news/canadian-high-commissioner-urges-media/' + u.should == 'http://ghanaian-chronicle.com/news/other-news/canadian-high-commissioner-urges-media' end end end context "clean" do @@ -170,14 +180,15 @@ def h(uri) PostRank::URI.hash(uri) end it "should compute MD5 hash of the normalized URI" do - hash = '021a1032b1ea631a7c33d1a0ccc562bf' + hash = '55fae8910d312b7878a3201ed653b881' - h('http://EverBurnign.Com/feed/post/1').should == hash - h('Everburnign.com/feed/post/1').should == hash - h('everburnign.com/feed/post/1').should == hash + h('http://EverBurning.Com/feed/post/1').should == hash + h('Everburning.com/feed/post/1').should == hash + h('everburning.com/feed/post/1').should == hash + h('everburning.com/feed/post/1/').should == hash end end context "extract" do def e(text)