Sha256: de1e490e122bd497e02c90fe0fe147ca8278484993fd07e02c48833195cd92b0

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

require "spec_helper"

describe Mascot::SiteController, type: :controller do
  context "templated page" do
    render_views
    before { get :show, resource_path: "/time" }
    let(:resource) { Mascot.configuration.site.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>Test layout</title>")
    end
    it "responds with content type" do
      expect(response.content_type).to eql("text/html")
    end
    context "helper methods" do
      subject { @controller }
      it "#current_page" do
        expect(subject.send(:current_page).asset.path).to eql(resource.asset.path)
      end
      it "#resources" do
        expect(subject.send(:resources)).to match_array(Mascot.configuration.site.resources)
      end
    end
  end

  context "static page" do
    render_views
    before { get :show, resource_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, resource_path: "/non-existent"
      }.to raise_exception(ActionController::RoutingError)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mascot-rails-0.1.15 spec/mascot/mascot_site_controller_spec.rb