Sha256: 1df1afee38897022dfc4c74ec079d956d1abcf036310469b86d5533968e49694

Contents?: true

Size: 1.3 KB

Versions: 9

Compression:

Stored size: 1.3 KB

Contents

require 'test/unit'
require 'helper'
require 'webgen/sourcehandler'
require 'stringio'

class TestSourceHandlerSitemap < Test::Unit::TestCase

  include Test::WebsiteHelper

  SITEMAP_CONTENT = <<EOF
---
site_url: http://example.com
default_change_freq: daily
EOF

  def setup
    super
    @nodes = create_sitemap_nodes
    @nodes.each {|k,v| v['modified_at'] = Time.now}
    @nodes[:file11_en]['priority'] = 0.9
    @nodes[:file11_en]['change_freq'] = 'hourly'
    @obj = Webgen::SourceHandler::Sitemap.new
    @path = path_with_meta_info('/test.sitemap', {}, @obj.class.name) {StringIO.new(SITEMAP_CONTENT)}
  end

  def test_create_node
    sitemap = @obj.create_node(@nodes[:root], @path)

    assert_not_nil(sitemap)
    assert_equal('/test.xml', sitemap.path)
    assert_equal('/test.xml', sitemap.absolute_lcn)

    assert_raise(RuntimeError) do
      @obj.create_node(@nodes[:root], path_with_meta_info('/test.sitemap', {}, @obj.class.name) {StringIO.new('')})
    end
  end

  def test_content
    sitemap = @obj.create_node(@nodes[:root], @path)
    content = sitemap.content
    assert_match(/<changefreq>daily<\/changefreq>/, content)
    assert_match(/<changefreq>hourly<\/changefreq>/, content)
    assert_match(/<priority>0.5<\/priority>/, content)
    assert_match(/<priority>0.9<\/priority>/, content)
  end

end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
gettalong-webgen-0.5.4.20080929 test/test_sourcehandler_sitemap.rb
gettalong-webgen-0.5.5.20081001 test/test_sourcehandler_sitemap.rb
gettalong-webgen-0.5.5.20081010 test/test_sourcehandler_sitemap.rb
gettalong-webgen-0.5.5.20081012 test/test_sourcehandler_sitemap.rb
gettalong-webgen-0.5.6.20081020 test/test_sourcehandler_sitemap.rb
webgen-0.5.4 test/test_sourcehandler_sitemap.rb
webgen-0.5.3 test/test_sourcehandler_sitemap.rb
webgen-0.5.6 test/test_sourcehandler_sitemap.rb
webgen-0.5.5 test/test_sourcehandler_sitemap.rb