Sha256: 6e020439791376fae6f79d771fa464709bc379d40f6dd1de3018ae8a0860cce4
Contents?: true
Size: 1.53 KB
Versions: 16
Compression:
Stored size: 1.53 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 %>). except("created_at", "updated_at") <%- 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
16 entries across 16 versions & 1 rubygems