Sha256: ee53a36fb68ea60d0d57240092d67938af2a0aedd450a5b8ac7f68e86f303483

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

# -*- encoding: utf-8 -*-

require 'url-identifier'

class DummyClass
end

describe UrlIdentifier do
	before(:each) do
	  @dummy_class = DummyClass.new
	  @dummy_class.extend(UrlIdentifier)
	end

	it "should get valid source and uid given a url" do
		@dummy_class.analyze("http://rosalieeve.blogspot.com/2013/01/military-print.html").should == {:source => 'rosalieeve.blogspot', :uid =>"/2013/01/military-print.html"}
		@dummy_class.analyze("http://rosalieeve.blogspot.com/2013/01/military-print.html?affiliate=true").should == {:source => 'rosalieeve.blogspot', :uid =>"/2013/01/military-print.html"}
		@dummy_class.analyze("http://rosalieeve.wordpress.com/?page=2333").should == {:source => 'rosalieeve.wordpress.com', :uid =>"/?page=2333"}
		@dummy_class.analyze("http://www.youtube.com/watch?v=9bZkp7q19f0").should == {:source=>'youtube', :uid=>'9bZkp7q19f0'}
		@dummy_class.analyze("http://youtu.be/X-7rixEph5s").should == {:source=>'youtube', :uid=>'X-7rixEph5s'}
		@dummy_class.analyze("http://lookbook.nu/look/5384932-Choies-Coat-Shirt-Romwe-Bag-Hat-Inspired-By-Freja-Beha").should == {:source => 'lookbook', :uid =>'5384932'}
		@dummy_class.analyze("http://www.shareasale.com/r.cfm?b=393018&u=314743&m=41271&afftrack=skim34712X927925Xea9dfabecfd3bfab249967985e2441f9&urllink=www.abc.com%2Fproduct%2Fadd-asa-dadsa").should == {:source => 'shareasale', :uid =>'skim34712X927925Xea9dfabecfd3bfab249967985e2441f9'}
		@dummy_class.analyze("http://www.fashiolista.com/item/12944315/").should == {:source => 'fashiolista', :uid =>'12944315'}
		@dummy_class.analyze("http://www.facebook.com/").should == {:source => 'facebook', :uid =>nil}
		@dummy_class.analyze("http://hello.blogspot.com/2013/09/tronchetti-mon-amour/?utm_source=rss&utm_medium=rss&utm_campaign=tronchetti-mon-amour").should == {:source => 'hello.blogspot', :uid => '/2013/09/tronchetti-mon-amour/'}
		@dummy_class.analyze("http://www.someunknownsite.com/?page=hello").should == {:source => 'someunknownsite.com', :uid => '/?page=hello'}
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
url-identifier-0.0.2 spec/url_identifier_spec.rb