Sha256: b3d9abef51325067836ac97e0c068d619d1bdd2ee0d1e3c330dde82505a5ae47

Contents?: true

Size: 1.71 KB

Versions: 17

Compression:

Stored size: 1.71 KB

Contents

require File.dirname(__FILE__) + '/../integration_helper'

require 'locomotive/steam/adapters/filesystem.rb'

describe Locomotive::Steam::Server do

  include Rack::Test::Methods

  def app
    run_server
  end

  describe 'sitemap.xml' do

    let(:now) { Time.use_zone('America/Chicago') { Time.zone.local(2015, 'mar', 25, 10, 0) } }
    let(:env) { {} }

    subject { Timecop.freeze(now) { get('/sitemap.xml', {}, env) }; last_response.body }

    before { Locomotive::Steam::Adapters::Filesystem::SimpleCacheStore.new.clear }

    it 'checks if it looks valid' do
      expect(Nokogiri::XML(subject).errors.empty?).to eq true
      expect(subject.scan(/<url>/).size).to eq 22
      expect(subject).to match("<loc>http://example.org/songs/song-number-2/band</loc>")
      expect(subject).to match(%(<xhtml:link rel="alternate" hreflang="fr" href="http://example.org/fr/a-notre-sujet" />))
      expect(subject).to match((<<-EOF
  <url>
    <loc>http://example.org/about-us</loc>
    <lastmod>2015-03-25</lastmod>
    <xhtml:link rel="alternate" hreflang="fr" href="http://example.org/fr/a-notre-sujet" />
     <xhtml:link rel="alternate" hreflang="nb" href="http://example.org/nb/om-oss" />
  </url>
      EOF
      ).strip)
    end

    context 'existing sitemap page' do

      let(:template)  { %{<?xml version="1.0" encoding="utf-8"?>OK</xml>} }
      let(:page)      { instance_double('Page', liquid_source: template, templatized?: false, redirect?: false, to_liquid: template, not_found?: false, response_type: 'application/xml') }
      let(:env)       { { 'steam.page' => page } }

      it 'renders the existing sitemap page' do
        expect(subject).to eq %{<?xml version="1.0" encoding="utf-8"?>OK</xml>}
      end

    end

  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.8.0.alpha1 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.7.1 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.7.0 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.6.1 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.6.0 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.6.0.rc1 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.6.0.beta1 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.5.3 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.5.2 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.5.1 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.5.0 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.5.0.rc1 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.5.0.rc0 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.5.0.beta3 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.5.0.beta2 spec/integration/server/sitemap_spec.rb
locomotivecms_steam-1.5.0.beta1 spec/integration/server/sitemap_spec.rb