Sha256: 71c8c925329d24e5d40659eb4e6f40de44c9cc0bc1c2403fd81012086dc7c01c

Contents?: true

Size: 832 Bytes

Versions: 3

Compression:

Stored size: 832 Bytes

Contents

require 'rails_helper'

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

    routes { Kawara::Engine.routes }

    describe 'GET #show' do
      subject { get :show, id: id }

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

      context 'when there is a published article' do
        let(:id) { published_article.id }

        before { subject }

        it { expect(response).to render_template(:show) }
        it { expect(response).to have_http_status(:success) }
        it { expect(assigns(:article)).to eq(published_article) }
      end

      context 'when there are no published articles' do
        let(:id) { draft_article.id }
        it { expect{subject}.to raise_error(ActiveRecord::RecordNotFound) }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kawara-0.2.0 spec/controllers/kawara/articles_controller_spec.rb
kawara-0.1.1 spec/controllers/kawara/articles_controller_spec.rb
kawara-0.1.0 spec/controllers/kawara/articles_controller_spec.rb