Open Fivell opened 7 years ago
@Fivell I don't have a lot of experience with generators. If you do, feel free to add it :)
We should start from somewhere, so I'm dropping this to here.
require 'rails_helper'
RSpec.describe Resource, type: :resource do
# let(:user) { create(:user) }
let(:data) { create() }
# Some attributes, creatable, updatable fields might be user related
# subject { described_class.new(data, { current_user: user }) }
subject { described_class.new(data, {}) }
it { is_expected.to have_primary_key(:id) }
context '#attributes' do
attributes = [:attribute]
attributes.each do |attribute|
it { is_expected.to have_attribute(attribute) }
end
end
context '#relationships' do
context '#one' do
# it { is_expected.to have_one(:relationship) }
end
context '#many' do
# it { is_expected.to have_many(:relationship) }
end
end
context '#filter' do
filters = [:field]
filters.each do |filter|
it { is_expected.to filter(filter) }
end
end
context '#fields' do
context '#sortable' do
sortables = [:field]
sortables.each do |sortable|
it { is_expected.to have_sortable_field(sortable) }
end
end
context '#creatable' do
context '#valid' do
fields = [:field]
fields.each do |field|
# it { is_expected.to have_creatable_field(field) }
end
end
context '#invalid' do
fields = [:field]
fields.each do |field|
# it { is_expected.to_not have_creatable_field(field) }
end
end
end
context '#updatable' do
context '#valid' do
fields = [:field]
fields.each do |field|
# it { is_expected.to_not have_updatable_field(field) }
end
end
context '#invalid' do
fields = [:field]
fields.each do |field|
# it { is_expected.to_not have_updatable_field(field) }
end
end
end
end
end
@Fivell
Hello, generator for resource spec file can be helpful