Sha256: ed9bda8d8d2e4b4e3c00d9ab7b0e1430308cf696190cff92e21066cd15a9833b
Contents?: true
Size: 1.7 KB
Versions: 11
Compression:
Stored size: 1.7 KB
Contents
require "spec_helper" describe "Relevance::Tarantula::HtmlDocumentHandler" do before do @handler = Relevance::Tarantula::HtmlDocumentHandler.new(nil) end it "does not write HTML Scanner warnings to the console" do bad_html = "<html><div></form></html>" err = Recording.stderr do @handler.handle(Relevance::Tarantula::Result.new(:response => stub(:html? => true, :body => bad_html))) end err.should == "" end it "ignores non-html" do @handler.expects(:queue_link).never @handler.handle(Relevance::Tarantula::Result.new(:response => stub(:html? => false, :body => '<a href="/foo">foo</a>'))) end it "queues anchor tags" do @handler.expects(:queue_link).with {|*args| args[0]['href'] == "/foo" && args[1] == nil} @handler.handle(Relevance::Tarantula::Result.new(:response => stub(:html? => true, :body => '<a href="/foo">foo</a>'))) end it "queues link tags" do @handler.expects(:queue_link).with {|*args| args[0]['href'] == "/bar" && args[1] == nil} @handler.handle(Relevance::Tarantula::Result.new(:response => stub(:html? => true, :body => '<link href="/bar">bar</a>'))) end it "queues forms" do @handler.expects(:queue_form).with{|tag,referrer| Hpricot::Elem === tag} @handler.handle(Relevance::Tarantula::Result.new(:url => "/page-url", :response => stub(:html? => true, :body => '<form>stuff</form>'))) end it "infers form action from page url if form is not explicit" do @handler.expects(:queue_form).with{|tag,referrer| tag['action'].should == '/page-url'; true } @handler.handle(Relevance::Tarantula::Result.new(:url => "/page-url", :response => stub(:html? => true, :body => '<form>stuff</form>'))) end end
Version data entries
11 entries across 11 versions & 2 rubygems