Sha256: 59888c97f61f86698b8f6beb1d2cab37509f3101d8acd6c2c1c3db019856bdd3
Contents?: true
Size: 838 Bytes
Versions: 32
Compression:
Stored size: 838 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
32 entries across 32 versions & 1 rubygems