@@ -268,6 +268,25 @@ describe Agents::WebsiteAgent do |
||
268 | 268 |
event.payload['url'].should == "http://xkcd.com/about" |
269 | 269 |
end |
270 | 270 |
|
271 |
+ it "should return an integer value if XPath evaluates to one" do |
|
272 |
+ rel_site = { |
|
273 |
+ 'name' => "XKCD", |
|
274 |
+ 'expected_update_period_in_days' => 2, |
|
275 |
+ 'type' => "html", |
|
276 |
+ 'url' => "http://xkcd.com", |
|
277 |
+ 'mode' => "on_change", |
|
278 |
+ 'extract' => { |
|
279 |
+ 'num_links' => {'css' => "#comicLinks", 'value' => "count(./a)"} |
|
280 |
+ } |
|
281 |
+ } |
|
282 |
+ rel = Agents::WebsiteAgent.new(:name => "xkcd", :options => rel_site) |
|
283 |
+ rel.user = users(:bob) |
|
284 |
+ rel.save! |
|
285 |
+ rel.check |
|
286 |
+ event = Event.last |
|
287 |
+ event.payload['num_links'].should == "9" |
|
288 |
+ end |
|
289 |
+ |
|
271 | 290 |
describe "JSON" do |
272 | 291 |
it "works with paths" do |
273 | 292 |
json = { |