Sha256: c24736f16a997764b6f3c9b55986b4af8402d4a8fd76f0456fa877b1e8abe8ca

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

# -*- encoding: utf-8 -*-

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

5 entries across 5 versions & 3 rubygems

Version Path
gettalong-webgen-0.5.7.20090227 test/test_sourcehandler_sitemap.rb
gettalong-webgen-0.5.8.20090507 test/test_sourcehandler_sitemap.rb
thewoolleyman-webgen-0.5.8.20090419 test/test_sourcehandler_sitemap.rb
webgen-0.5.7 test/test_sourcehandler_sitemap.rb
webgen-0.5.8 test/test_sourcehandler_sitemap.rb