Sha256: 77614b83f38fb6b8fa13fbf59a162873252c6b31919ade284e2d29e02141cd11

Contents?: true

Size: 1.51 KB

Versions: 3

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

describe Doculab::DocsController do
  describe "layout selection" do
    before(:each) do
      reset_layouts!
    end
    
    after(:each) do
      reset_layouts!
    end

    context "with the default layouts" do
      it "uses the 'docs' layout for the index page" do
        get :index
        controller.send(:_layout).should == 'docs'
      end
      
      it "uses the 'docs' layout for a doc page" do
        get :show, :permalink => good_permalink
        controller.send(:_layout).should == 'docs'
      end
    end
    
    context "with a custom main_layout" do
      before(:each) do
        Doculab.main_layout = 'custom'
      end
      
      it "uses the 'custom' layout for the index page" do
        get :index
        controller.send(:_layout).should == 'custom'
      end
      
      it "uses the 'custom' layout for a doc page" do
        get :show, :permalink => good_permalink
        controller.send(:_layout).should == 'custom'
      end
    end

    context "with a custom index_layout" do
      before(:each) do
        Doculab.index_layout = 'custom'
      end
      
      it "uses the 'custom' layout for the index page" do
        get :index
        controller.send(:_layout).should == 'custom'
      end
      
      it "uses the 'docs' layout for a doc page" do
        get :show, :permalink => good_permalink
        controller.send(:_layout).should == 'docs'
      end
    end
    
    def reset_layouts!
      Doculab.main_layout = nil
      Doculab.index_layout = nil
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
doculab-0.2.0 spec/controllers/docs_controller_spec.rb
doculab-0.1.1 spec/controllers/docs_controller_spec.rb
doculab-0.1.0 spec/controllers/docs_controller_spec.rb