Sha256: 2b8c0f89c01c3ff7504a456d4bf3827199fb3e6d9a8a0d44d25aba4086745320
Contents?: true
Size: 835 Bytes
Versions: 5
Compression:
Stored size: 835 Bytes
Contents
RSpec.shared_examples 'a controller actions' do |factory| let(:entity) { FactoryBot.create(factory) } let(:entities_list) { FactoryBot.create_list(factory, 3) } it '#index' do entities_list get :index, params: { use_route: 'admin' } expect(response).to have_http_status(:success) end it '#destroy' do entity # touch expect { delete :destroy, params: { id: entity } }.to change(entity.class, :count).by(-1) end context 'json' do it '#index' do entities_list get :index, params: { use_route: 'admin', format: 'json' } expect(response).to have_http_status(:success) end it '#show' do get :show, params: {id: entity, format: 'json'} expect(response).to have_http_status(:success) expect(response.body).to include "id", entity.id.to_s end end end
Version data entries
5 entries across 5 versions & 1 rubygems