Added test for relative paths

This commit is contained in:
Kevin Lindecke 2013-04-03 17:42:53 +02:00
parent 49a0057ad4
commit cd7f23aa50

View file

@ -51,6 +51,26 @@ describe Agents::WebsiteAgent do
event.payload[:title].should =~ /^Biologists play reverse/
end
it "should turn relative urls to absolute" do
rel_site = {
:name => "XKCD",
:expected_update_period_in_days => 2,
:type => "html",
:url => "http://xkcd.com",
:mode => :on_change,
:extract => {
:url => {:css => "#topLeft a", :attr => "href"},
:title => {:css => "#topLeft a", :text => "true"}
}
}
rel = Agents::WebsiteAgent.new(:name => "xkcd", :options => rel_site)
rel.user = users(:bob)
rel.save!
rel.check
event = Event.last
event.payload[:url].should == "http://imgs.xkcd.com/about"
end
describe "JSON" do
it "works with paths" do
json = {
@ -120,4 +140,4 @@ describe Agents::WebsiteAgent do
end
end
end
end
end