Sha256: 5573185871b2a1acea9072ad03933f665d315772ea54dfb7188d1f5d011683dc

Contents?: true

Size: 860 Bytes

Versions: 31

Compression:

Stored size: 860 Bytes

Contents

RSpec.shared_examples 'a requests 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' }
    get polymorphic_path(factory.to_s.pluralize)
    expect(response).to have_http_status(:success)
  end

  it '#destroy' do
    entity # touch
    expect { delete polymorphic_path(entity) }.to change(entity.class, :count).by(-1)
  end

  context 'json' do

    it '#index' do
      entities_list
      get polymorphic_path(factory.to_s.pluralize, format: "json")
      expect(response).to have_http_status(:success)
    end

    it '#show' do
      get polymorphic_path(entity)
      expect(response).to have_http_status(:success)
      expect(response.body).to include "id", entity.id.to_s
    end
  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

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