Sha256: e657d76e16c23bea9c71e4981f684b62601a0ea2178b55fac28f4d15a2f507be
Contents?: true
Size: 1.17 KB
Versions: 6
Compression:
Stored size: 1.17 KB
Contents
require 'spidr/actions' require 'spidr/agent' require 'spec_helper' describe Actions do let(:url) { URI('http://spidr.rubyforge.org/') } it "should be able to pause spidering" do count = 0 agent = Agent.host('spidr.rubyforge.org') do |spider| spider.every_page do |page| count += 1 spider.pause! if count >= 2 end end agent.should be_paused agent.history.length.should == 2 end it "should be able to continue spidering after being paused" do agent = Agent.new do |spider| spider.every_page do |page| spider.pause! end end agent.enqueue(url) agent.continue! agent.visited?(url).should == true end it "should allow skipping of enqueued links" do agent = Agent.new do |spider| spider.every_url do |url| spider.skip_link! end end agent.enqueue(url) agent.queue.should be_empty end it "should allow skipping of visited pages" do agent = Agent.new do |spider| spider.every_page do |url| spider.skip_page! end end agent.visit_page(url) agent.history.should == Set[url] agent.queue.should be_empty end end
Version data entries
6 entries across 6 versions & 2 rubygems