Sha256: eb929d42b52ca6eaa2da2a695d287d79f5961fc775a71ac6e8b14e44642fe4e6

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require "spec_helper"

describe StyleGuide::StyleController do
  let(:temp_path) { Dir.mktmpdir }
  let(:partial_path) { File.join(temp_path, "monkey_hammer") }

  before do
    FileUtils.mkdir_p(partial_path)
    StyleGuide::Engine.config.style_guide.stub(:partial_paths => [partial_path])
  end

  describe "#index" do
    it "assigns sections" do
      get :index, use_route: :styles
      assigns(:sections).should be
      assigns(:sections).should have(1).section
      assigns(:sections).first.should be_a StyleGuide::Section
    end

    it "sets the active section to the first one" do
      get :index, use_route: :styles
      assigns(:active).should == assigns(:sections).first
      assigns(:active).title.should == "Monkey Hammer"
    end
  end

  describe "#show" do
    let(:fake_section) { StyleGuide::Section.new(partial_path) }

    it "assigns sections" do
      get :show, id: fake_section.id, use_route: :styles
      assigns(:sections).should be
      assigns(:sections).should have(1).section
      assigns(:sections).first.should be_a StyleGuide::Section
    end

    it "assigns the section" do
      get :show, id: fake_section.id, use_route: :styles
      assigns(:active).should be_a StyleGuide::Section
      assigns(:active).title.should == "Monkey Hammer"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
style-guide-0.4.0 spec/controllers/style_guide/style_controller_spec.rb
style-guide-0.3.0 spec/controllers/style_guide/style_controller_spec.rb
style-guide-0.2.1 spec/controllers/style_guide/style_controller_spec.rb
style-guide-0.2.0 spec/controllers/style_guide/style_controller_spec.rb