Sha256: 4a6cd5cb61dab0a4fc1d36d660b03f2b119d5db48dabd26f9299d31e48d8bf9f
Contents?: true
Size: 1.41 KB
Versions: 6
Compression:
Stored size: 1.41 KB
Contents
require 'spidr/sanitizers' require 'spidr/agent' require 'spec_helper' describe Sanitizers do describe "sanitize_url" do let(:url) { 'http://host.com' } before(:all) { @agent = Agent.new } 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 let(:url) { URI("http://host.com/page#lol") } 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 let(:url) { URI("http://host.com/page?x=1") } 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 & 2 rubygems