Sha256: 7591bc8649adcb9641c0b4b9d9a0409ae9736ce99713d271c8fbf51e10f37ba6
Contents?: true
Size: 1.46 KB
Versions: 6
Compression:
Stored size: 1.46 KB
Contents
require 'spidr/sanitizers' require 'spidr/agent' require 'spec_helper' describe Sanitizers do describe "sanitize_url" do before(:all) do @agent = Agent.new @url = 'http://host.com' end it "should sanitize URLs" do agent = Agent.new clean_url = agent.sanitize_url(URI(@url)) clean_url.host.should == 'host.com' end it "should sanitize URLs given as Strings" do agent = Agent.new clean_url = agent.sanitize_url(@url) clean_url.host.should == 'host.com' end end describe "strip_fragments" do before(:all) do @url = URI("http://host.com/page#lol") end it "should strip fragment components by default" do agent = Agent.new clean_url = agent.sanitize_url(@url) clean_url.fragment.should be_nil end it "should allow perserving fragment components" do agent = Agent.new(:strip_fragments => false) clean_url = agent.sanitize_url(@url) clean_url.fragment.should == 'lol' end end describe "strip_query" do before(:all) do @url = URI("http://host.com/page?x=1") end it "should not strip query components by default" do agent = Agent.new clean_url = agent.sanitize_url(@url) clean_url.query.should == 'x=1' end it "should allow stripping of query components" do agent = Agent.new(:strip_query => true) clean_url = agent.sanitize_url(@url) clean_url.query.should be_nil end end end
Version data entries
6 entries across 6 versions & 1 rubygems