Sha256: 6e27ee7c46327f3ac179662d1de1b29242834ab67ed56f59bae2b2ed9a9f92df
Contents?: true
Size: 1.59 KB
Versions: 3
Compression:
Stored size: 1.59 KB
Contents
require 'rails_helper' module Kawara RSpec.describe ArticlesController, 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 no published article' 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_array(Kawara::Article.none) } end 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 end 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