Sha256: e50d51d06ec29819f85ef75c4f91f1dc1bf794257200b641bac636398e895974

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'
require 'nokogiri'

describe "Search engine sitemaps", :feature do
  include XmlHelpers

  it "produces a sitemap" do
    run_site 'dummy' do
      set :url_root, 'http://example.com'
      activate :search_engine_sitemap
    end

    visit '/sitemap.xml'
    
    schema = File.expand_path('../../../sitemap.xsd', __FILE__)
    doc = Nokogiri::XML(last_response.body)
    expect(doc).to validate_against_schema(schema)

    expect(doc).to contain_node('url').with_children(
      'loc'        => 'http://example.com/home.html',
      'priority'   => '0.5',
      'changefreq' => 'monthly'
    )

    expect(doc).to contain_node('url').with_children(
      'loc'        => 'http://example.com/about.html',
      'priority'   => '0.2',
      'changefreq' => 'monthly'
    )

    expect(doc).to contain_node('url').with_children(
      'loc'        => 'http://example.com/blog.html',
      'priority'   => '0.5',
      'changefreq' => 'daily'
    )
  end

  it "works with directory indexes" do
    run_site 'dummy' do
      set :url_root, 'http://example.com'
      activate :directory_indexes
      activate :search_engine_sitemap
    end

    visit '/sitemap.xml'
    doc = Nokogiri::XML(last_response.body)

    expect(doc).to contain_node('url').with_children(
      'loc'        => 'http://example.com/home/',
      'priority'   => '0.5',
      'changefreq' => 'monthly'
    )

    expect(doc).to contain_node('url').with_children(
      'loc'        => 'http://example.com/about/',
      'priority'   => '0.2',
      'changefreq' => 'monthly'
    )

    expect(doc).to contain_node('url').with_children(
      'loc'        => 'http://example.com/blog/',
      'priority'   => '0.5',
      'changefreq' => 'daily'
    )
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
middleman-search_engine_sitemap-1.0.1 spec/features/sitemap_feature_spec.rb
middleman-search_engine_sitemap-1.0.0 spec/features/sitemap_feature_spec.rb