Sha256: 47d86262031d2187c9579008e0425e5a666a9203fcf4d986181bedf6500ec78f

Contents?: true

Size: 1.3 KB

Versions: 16

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

describe Fuel::PostsController, type: :controller do

  routes { Fuel::Engine.routes }

  describe 'GET #index' do

    let(:number_posts) { 10 }
    let(:posts) { create_list(:published_post, number_posts) }
    let(:unpublished_post) { create(:post) }

    before(:each) do
      posts
      unpublished_post
    end

    it "populates an array of posts" do
      get :index
      expect(assigns(:posts).count).to be > 0
    end
    it "populates an array of posts that is not greater than the paginates number" do
      get :index
      expect(assigns(:posts).count).to be <= Fuel.configuration.paginates_per
    end
    it "renders the :index view" do
      get :index
      expect(response).to render_template(:index)
    end
  end

  describe 'GET #show' do

    let(:post) { create(:published_post) }

    before :each do
      post
    end

    it "assigns the requested post to @post using slug" do
      get :show, id: post.slug
      expect(assigns(:post)).to eq post
    end

    it "assigns the requested post to @post using ID" do
      get :show, id: post.id
      expect(assigns(:post)).to eq post
    end

    it "truncates title to 70 characters or less" do
      get :show, id: post.slug
      title_length = assigns(:title).length
      expect(title_length).to be < 70
    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fuel-0.4.10 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.4.9 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.4.8 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.4.7 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.4.6 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.4.5 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.4.4 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.4.3 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.4.2 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.4.1 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.3.34 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.3.33 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.3.32 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.3.31 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.3.30 spec/controllers/fuel/posts_controller_spec.rb
fuel-0.3.29 spec/controllers/fuel/posts_controller_spec.rb