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

Version Path
symphonia-6.0.6 spec/support/shared_controllers.rb
symphonia-6.0.5 spec/support/shared_controllers.rb
symphonia-6.0.2 spec/support/shared_controllers.rb
symphonia-6.0.1 spec/support/shared_controllers.rb
symphonia-6.0.0 spec/support/shared_controllers.rb
symphonia-5.0.6 spec/support/shared_controllers.rb
symphonia-5.0.5 spec/support/shared_controllers.rb
symphonia-5.0.4 spec/support/shared_controllers.rb
symphonia-5.0.3 spec/support/shared_controllers.rb
symphonia-5.0.0 spec/support/shared_controllers.rb
symphonia-4.2.0 spec/support/shared_controllers.rb
symphonia-4.1.3 spec/support/shared_controllers.rb
symphonia-4.1.2 spec/support/shared_controllers.rb
symphonia-4.1.1 spec/support/shared_controllers.rb
symphonia-4.1.0 spec/support/shared_controllers.rb
symphonia-4.0.1 spec/support/shared_controllers.rb
symphonia-4.0.0 spec/support/shared_controllers.rb
symphonia-3.4.0 spec/support/shared_controllers.rb
symphonia-3.3.4 spec/support/shared_controllers.rb
symphonia-3.3.3 spec/support/shared_controllers.rb