Sha256: 9c8848ee929fb297b27167f3c3855a845c7690620f395ec493d8b17f1b4bae89

Contents?: true

Size: 929 Bytes

Versions: 4

Compression:

Stored size: 929 Bytes

Contents

require 'rails_helper'

module Kawara
  RSpec.describe HomeController, type: :controller do

    routes { Kawara::Engine.routes }

    describe 'GET #index' do
      subject { get :index }

      let(:draft_article) { create :draft_article }
      let(:published_article) { create :published_article }

      context 'when there is a published article' do
        before { published_article; subject }
        it { expect(response).to render_template(:index) }
        it { expect(response).to have_http_status(:success) }
        it { expect(assigns(:articles)).to match_array published_article }
      end

      context 'when there are no published articles' do
        before { draft_article; subject }

        it { expect(response).to render_template(:index) }
        it { expect(response).to have_http_status(:success) }
        it { expect(assigns(:articles)).to match Kawara::Article.none }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kawara-0.3.2 spec/controllers/kawara/home_controller_spec.rb
kawara-0.3.1 spec/controllers/kawara/home_controller_spec.rb
kawara-0.3.0 spec/controllers/kawara/home_controller_spec.rb
kawara-0.2.0 spec/controllers/kawara/home_controller_spec.rb