Sha256: 1bd76cc1d2670c59369b97d3b41c6325df7d4888715b9f6fbbb7341e2861bcfc
Contents?: true
Size: 1.49 KB
Versions: 78
Compression:
Stored size: 1.49 KB
Contents
require 'rails_helper' RSpec.describe <%= resource_class %>, type: :resource do describe 'creating' do let(:payload) do { data: { type: '<%= type %>', <%- if defined?(FactoryBot) -%> attributes: attributes_for(:<%= type.to_s.singularize %>) <%- else -%> attributes: { } <%- end -%> } } end let(:instance) do <%= resource_class %>.build(payload) end it 'works' do expect { expect(instance.save).to eq(true), instance.errors.full_messages.to_sentence }.to change { <%= model_class %>.count }.by(1) end end describe 'updating' do let!(:<%= var %>) { create(:<%= var %>) } let(:payload) do { data: { id: <%= var %>.id.to_s, type: '<%= type %>', attributes: { } # Todo! } } end let(:instance) do <%= resource_class %>.find(payload) end xit 'works (add some attributes and enable this spec)' do expect { expect(instance.update_attributes).to eq(true) }.to change { <%= var %>.reload.updated_at } # .and change { <%= var %>.foo }.to('bar') <- example end end describe 'destroying' do let!(:<%= var %>) { create(:<%= var %>) } let(:instance) do <%= resource_class %>.find(id: <%= var %>.id) end it 'works' do expect { expect(instance.destroy).to eq(true) }.to change { <%= model_class %>.count }.by(-1) end end end
Version data entries
78 entries across 78 versions & 2 rubygems