test/test_helper.rb in crawlable-0.0.1.5 vs test/test_helper.rb in crawlable-0.0.1.6
- old
+ new
@@ -7,12 +7,55 @@
require 'active_record'
require 'active_record/fixtures'
require 'shoulda'
require 'shoulda/active_record'
+this = File.expand_path(File.dirname(__FILE__))
+require File.expand_path(File.join(this, '/../lib/crawlable'))
+
+Dir["#{this}/lib/*"].each { |c| require c if File.extname(c) == ".rb" }
require File.expand_path(File.join(File.dirname(__FILE__), '/../lib/crawlable'))
ActiveRecord::Base.class_eval do
def self.detonate
all.map(&:destroy)
+ end
+end
+
+ActiveSupport::TestCase.class_eval do
+
+ def create_posts(many = 10)
+ many.times do |i|
+ Post.create!(:title => "title-#{i.to_s}")
+ end
+ end
+
+ def load_sitemap
+ Sitemap "http://www.example.com" do
+ ping :yahoo, :google
+
+ link "/posts", :priority => 0.7, :changes => 'daily' do
+ 3.times do |i|
+ image "/images/#{i}"
+ end
+ end
+
+ Post.all.each do |a|
+ link "/posts/#{a.to_param}", :updated_at => a.updated_at
+ end
+ end
+ end
+
+ def load_feed
+ Feed do
+ posts do
+ title "My RSS Feed"
+ author "Lance Pollard"
+ description "Something nice and tidy"
+
+ Post.all.each do |a|
+ entry "/posts/#{a.to_param}", :updated_at => a.updated_at, :title => a.title
+ end
+ end
+ end
end
end