Sha256: c1eba283f6650e51dda33bbc294ff4606c340113eb08b6728cfc187291c6e349
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
require 'rubygems' require 'bundler/setup' require 'test/unit' require 'shoulda' require 'mocha' require 'test/fixtures/test_model' require 'big_sitemap' class Test::Unit::TestCase #TestHelper private def generate_sitemap(options={}, &block) BigSitemap.generate(options.merge(:base_url => 'http://example.com', :document_root => tmp_dir), &block) end def delete_tmp_files Dir["#{sitemaps_dir}/sitemap*"].each do |f| FileUtils.rm_rf f end end def sitemaps_index_file "#{unzipped_sitemaps_index_file}.gz" end def unzipped_sitemaps_index_file "#{sitemaps_dir}/sitemap_index.xml" end def unzipped_first_sitemap_file "#{sitemaps_dir}/sitemap.xml" end def first_sitemap_file "#{sitemaps_dir}/sitemap.xml.gz" end def second_sitemap_file "#{sitemaps_dir}/sitemap_1.xml.gz" end def third_sitemap_file "#{sitemaps_dir}/sitemap_2.xml.gz" end def sitemaps_dir tmp_dir end def tmp_dir '/tmp' end def ns {'s' => 'http://www.sitemaps.org/schemas/sitemap/0.9'} end def elements(filename, el) file_class = filename.include?('.gz') ? Zlib::GzipReader : File data = Nokogiri::XML.parse(file_class.open(filename).read) data.search("//s:#{el}", ns) end def num_elements(filename, el) elements(filename, el).size end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
big_sitemap-1.1.0 | test/test_helper.rb |
big_sitemap-1.0.2 | test/test_helper.rb |