| Class | SeoToolboxTest |
| In: |
test/seo_toolbox_test.rb
|
| Parent: | Test::Unit::TestCase |
# File test/seo_toolbox_test.rb, line 10
10: def setup
11: @working_path = (`pwd`).strip+"/test/temp"
12: @seo_toolbox = SeoToolbox.new("#{@working_path}", "#{@working_path}", "http://blog.media-scientific.com", "weekly", "1.0")
13: end
# File test/seo_toolbox_test.rb, line 50
50: def test_create_robots_txt
51: assert @seo_toolbox.create_robots_txt?(nil, @working_path)
52: assert File.exists?("#{@working_path}/robots.txt")
53: f = File.open("#{@working_path}/robots.txt", "r")
54: assert f.grep(/User-Agent/)
55: assert f.grep(/Allow/)
56: assert f.grep(/blog.media-scientific.com/)
57: end
# File test/seo_toolbox_test.rb, line 42
42: def test_create_xml_sitemap
43: assert @seo_toolbox.save_new_url_to_sitemap?("http://blog.media-scientific.com/noch_ein_test.html", DateTime.now.strftime("%Y-%m-%d %H:%M"), "daily", "0.5")
44: assert @seo_toolbox.create_xml_sitemap?
45: assert File.exists?("#{@working_path}/sitemap.xml")
46: f = File.open("#{@working_path}/sitemap_data.dat", "r")
47: assert f.grep(/noch_ein_test.html/)
48: end
# File test/seo_toolbox_test.rb, line 23
23: def test_create_xml_sitemap_after_deploy
24: File.delete("#{@working_path}/sitemap.xml") if File.exists?("#{@working_path}/sitemap.xml")
25: setup
26: assert File.exists?("#{@working_path}/sitemap.xml")
27: end
# File test/seo_toolbox_test.rb, line 59
59: def test_delete_file_form_sitemap
60: assert @seo_toolbox.save_new_url_to_sitemap?("http://blog.media-scientific.com/erster_test.html", DateTime.now.strftime("%Y-%m-%d %H:%M"), "daily", "0.5")
61: assert @seo_toolbox.remove_url_from_sitemap? "http://blog.media-scientific.com/erster_test.html"
62: f = File.open("#{@working_path}/sitemap_data.dat", "r")
63: assert f.grep(/erster_test.html/)
64: end
# File test/seo_toolbox_test.rb, line 35
35: def test_include_metatags
36: ret_str = SeoToolbox.include_metatags({:keywords => 'test1', :description => 'das ist ein test', :author => 'Philipp', :language => 'DE', :robots => 'allow'})
37: assert_match /<meta/, ret_str
38: assert_match /content="Philipp"/, ret_str
39: assert_equal "<meta name=\"robots\" content=\"allow\" />\n<meta name=\"keywords\" content=\"test1\" />\n<meta name=\"description\" content=\"das ist ein test\" />\n<meta name=\"author\" content=\"Philipp\" />\n<meta name=\"language\" content=\"DE\" />\n<!--This site use the seo_toolbox gem from Philipp Petersen-->", ret_str
40: end
# File test/seo_toolbox_test.rb, line 15
15: def test_initializing
16: assert @seo_toolbox.class == SeoToolbox
17: assert_equal "#{@working_path}", @seo_toolbox.path_to_data
18: assert_equal "#{@working_path}", @seo_toolbox.path_to_sitemap
19: assert_equal "http://blog.media-scientific.com", @seo_toolbox.url
20: assert File.exists?("#{@working_path}/sitemap_data.dat")
21: end
# File test/seo_toolbox_test.rb, line 29
29: def test_save_new_url_to_sitemap
30: assert @seo_toolbox.save_new_url_to_sitemap?("http://blog.media-scientific.com/erster_test.html", DateTime.now.strftime("%Y-%m-%d %H:%M"), "daily", "0.5")
31: f = File.open("#{@working_path}/sitemap_data.dat", "r")
32: assert f.grep(/erster_test.html/)
33: end