Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move test helper mouthed to test helper

  • Loading branch information...
commit fe67feb15ba4a41d3b068bdfcf15172cd8bb81e7 1 parent bcbee4e
@rngtng rngtng authored
Showing with 58 additions and 56 deletions.
  1. +0 −56 test/big_sitemap_test.rb
  2. +58 −0 test/test_helper.rb
View
56 test/big_sitemap_test.rb
@@ -336,60 +336,4 @@ def teardown
end
end
- 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
View
58 test/test_helper.rb
@@ -9,4 +9,62 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.