Sha256: d9ddb97e7c08c4317fb2600d14a50bf6a67a6fa4f4257e982a4dfec207600216
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
require 'rails_helper' module Kawara RSpec.describe CategoriesController, type: :controller do routes { Kawara::Engine.routes } describe 'GET #index' do subject { get :index } before { subject } context 'when there is no tag' do it { expect(response).to render_template(:index) } it { expect(response).to have_http_status(:success) } it { expect(assigns(:categories)).to match_array(Kawara::Category.none) } end end describe 'GET #show' do subject { get :show, id: id } let(:category) { create :kawara_category } let(:category_with_published_articles) { create :kawara_category_with_published_articles } context 'when there are related articles' do let(:id) { category_with_published_articles.id } before { subject } it { expect(response).to render_template(:show) } it { expect(response).to have_http_status(:success) } it { expect(assigns(:articles)).to match(category_with_published_articles.articles_latest) } end context 'when there are no related articles' do let(:id) { category.id } before { subject } it { expect(response).to render_template(:show) } it { expect(response).to have_http_status(:success) } it { expect(assigns(:articles)).to match Kawara::Category.none } end context 'when there are no articles' do let(:id) { 1 } it { expect{subject}.to raise_error(ActiveRecord::RecordNotFound) } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kawara-0.2.0 | spec/controllers/kawara/categories_controller_spec.rb |