402
408
@robots_mybot = WebRobots.new('MyBot', :http_get => http_get)
409
@robots_mybot_ignore = WebRobots.new('MyBot', :http_get => http_get, :crawl_delay => :ignore)
410
@robots_mybot_custom = WebRobots.new('MyBot', :http_get => http_get, :crawl_delay => proc { |*args| @delay_args = args })
411
@robots_herbot = WebRobots.new('HerBot', :http_get => http_get)
403
412
@robots_hisbot = WebRobots.new('HisBot', :http_get => http_get)
411
420
assert_equal 'Hello', @robots_mybot.option('http://www.example.org/', 'Option2')
412
421
assert_equal 'Hello', options['option2']
423
options = @robots_mybot_ignore.options('http://www.example.org/')
424
assert_equal 2, options.size
425
assert_equal 'Foo', @robots_mybot_ignore.option('http://www.example.org/', 'Option1')
426
assert_equal 'Foo', options['option1']
427
assert_equal 'Hello', @robots_mybot_ignore.option('http://www.example.org/', 'Option2')
428
assert_equal 'Hello', options['option2']
430
options = @robots_mybot_custom.options('http://www.example.org/')
431
assert_equal 2, options.size
432
assert_equal 'Foo', @robots_mybot_custom.option('http://www.example.org/', 'Option1')
433
assert_equal 'Foo', options['option1']
434
assert_equal 'Hello', @robots_mybot_custom.option('http://www.example.org/', 'Option2')
435
assert_equal 'Hello', options['option2']
437
options = @robots_herbot.options('http://www.example.org/')
438
assert_equal 2, options.size
439
assert_equal 'Baz', @robots_herbot.option('http://www.example.org/', 'Option1')
440
assert_equal 'Baz', options['option1']
441
assert_equal 'Qux', @robots_herbot.option('http://www.example.org/', 'Option2')
442
assert_equal 'Qux', options['option2']
414
444
options = @robots_hisbot.options('http://www.example.org/')
415
445
assert_equal 2, options.size
416
446
assert_equal 'Bar', @robots_hisbot.option('http://www.example.org/', 'Option1')
426
456
http://www.example.org/sitemap-host1.xml
427
457
http://www.example.org/sitemap-host2.xml
458
], @robots_mybot_ignore.sitemaps('http://www.example.org/')
460
http://www.example.org/sitemap-host1.xml
461
http://www.example.org/sitemap-host2.xml
462
], @robots_herbot.sitemaps('http://www.example.org/')
464
http://www.example.org/sitemap-host1.xml
465
http://www.example.org/sitemap-host2.xml
428
466
], @robots_hisbot.sitemaps('http://www.example.org/')
468
assert_equal 1.5, @robots_mybot.crawl_delay('http://www.example.org/')
469
assert_equal 1.5, @robots_mybot_ignore.crawl_delay('http://www.example.org/')
470
assert_equal 1.5, @robots_mybot_custom.crawl_delay('http://www.example.org/')
471
assert_equal 0, @robots_herbot.crawl_delay('http://www.example.org/')
472
assert_equal 0, @robots_hisbot.crawl_delay('http://www.example.org/')
431
475
@robots_mybot.allowed?('http://www.example.org/')
432
476
@robots_mybot.allowed?('http://www.example.org/article1.html')
435
479
@robots_mybot.allowed?('http://www.example.org/article2.html')
437
481
assert_in_delta 1.5, t3 - t2, 0.1
484
@robots_mybot_ignore.allowed?('http://www.example.org/')
485
@robots_mybot_ignore.allowed?('http://www.example.org/article1.html')
487
assert_in_delta 0, t2 - t1, 0.1
488
@robots_mybot_ignore.allowed?('http://www.example.org/article2.html')
490
assert_in_delta 0, t3 - t2, 0.1
493
@robots_mybot_custom.allowed?('http://www.example.org/')
494
@robots_mybot_custom.allowed?('http://www.example.org/article1.html')
496
assert_in_delta 0, t2 - t1, 0.1
497
assert_instance_of Array, @delay_args
498
assert_equal 2, @delay_args.size
499
assert_equal 1.5, @delay_args[0]
500
assert_instance_of Time, @delay_args[1]