@@ -51,6 +51,26 @@ describe Agents::WebsiteAgent do |
||
| 51 | 51 |
event.payload[:title].should =~ /^Biologists play reverse/ |
| 52 | 52 |
end |
| 53 | 53 |
|
| 54 |
+ it "should turn relative urls to absolute" do |
|
| 55 |
+ rel_site = {
|
|
| 56 |
+ :name => "XKCD", |
|
| 57 |
+ :expected_update_period_in_days => 2, |
|
| 58 |
+ :type => "html", |
|
| 59 |
+ :url => "http://xkcd.com", |
|
| 60 |
+ :mode => :on_change, |
|
| 61 |
+ :extract => {
|
|
| 62 |
+ :url => {:css => "#topLeft a", :attr => "href"},
|
|
| 63 |
+ :title => {:css => "#topLeft a", :text => "true"}
|
|
| 64 |
+ } |
|
| 65 |
+ } |
|
| 66 |
+ rel = Agents::WebsiteAgent.new(:name => "xkcd", :options => rel_site) |
|
| 67 |
+ rel.user = users(:bob) |
|
| 68 |
+ rel.save! |
|
| 69 |
+ rel.check |
|
| 70 |
+ event = Event.last |
|
| 71 |
+ event.payload[:url].should == "http://imgs.xkcd.com/about" |
|
| 72 |
+ end |
|
| 73 |
+ |
|
| 54 | 74 |
describe "JSON" do |
| 55 | 75 |
it "works with paths" do |
| 56 | 76 |
json = {
|
@@ -120,4 +140,4 @@ describe Agents::WebsiteAgent do |
||
| 120 | 140 |
end |
| 121 | 141 |
end |
| 122 | 142 |
end |
| 123 |
-end |
|
| 143 |
+end |