Sha256: 1e843574697e493fcb7e10a512e51f44c4dc9dac82a88ced65f384c406a8d54e

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

require "spec_helper"

describe Mascot::SitemapController, type: :controller do
  context "existing templated page" do
    render_views
    before { get :show, path: "/time" }
    let(:resource) { Mascot.configuration.sitemap.get("/time") }
    it "is status 200" do
      expect(response.status).to eql(200)
    end
    it "renders body" do
      expect(response.body).to include("<h1>Tick tock, tick tock</h1>")
    end
    it "renders layout" do
      expect(response.body).to include("<title>Dummy</title>")
    end
    it "responds with content type" do
      expect(response.content_type).to eql("text/html")
    end
    context "@_mascot_locals assignment" do
      subject { assigns(:_mascot_locals) }
      it ":current_page" do
        expect(subject[:current_page].asset.path).to eql(resource.asset.path)
      end
      it ":sitemap" do
        expect(subject[:resources]).to eql(Mascot.configuration.resources)
      end
    end
  end

  context "existing static page" do
    render_views
    before { get :show, path: "/hi" }
    it "is status 200" do
      expect(response.status).to eql(200)
    end
    it "renders body" do
      expect(response.body).to include("<h1>Hi!</h1>")
    end
    it "renders layout" do
      expect(response.body).to include("<title>Dummy</title>")
    end
    it "responds with content type" do
      expect(response.content_type).to eql("text/html")
    end
  end

  context "non-existent page" do
    it "is status 404" do
      expect {
        get :show, path: "/non-existent"
      }.to raise_exception(ActionController::RoutingError)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mascot-rails-0.1.8 spec/mascot/mascot_sitemap_controller_spec.rb
mascot-rails-0.1.7 spec/mascot/mascot_sitemap_controller_spec.rb
mascot-rails-0.1.6 spec/mascot/mascot_sitemap_controller_spec.rb