Last active
November 17, 2022 21:18
-
-
Save tellodaniel/dff0ef8580d7f4b6a85ecf41fdd24999 to your computer and use it in GitHub Desktop.
Tello model cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe Model, type: :model do | |
it { expect(described_class).to be < OtherModel } | |
describe 'associations' do | |
it { should belong_to(:carrier).optional } | |
it { should belong_to(:zip_code).with_foreign_key('geolocation_id').class_name('Geolocation') } | |
it { should have_one(:facility_procedure).required } | |
it { should have_many(:companies).through(:other_table) } | |
it { should accept_nested_attributes_for(:facility_procedure) } | |
end | |
describe 'has_paper_trail' do | |
it 'enables paper trail' do | |
is_expected.to be_versioned | |
end | |
end | |
describe 'validations' do | |
it { should validate_presence_of(:name) } | |
it { should define_enum_for(:enum).with_values(Model.enums).backed_by_column_of_type(:string) } | |
end | |
describe 'delegators' do | |
it { should delegate_method(:country).to(:zip_code).allow_nil } | |
end | |
describe 'callbacks' do | |
end | |
describe 'scopes' do | |
end | |
describe '#public_method' do | |
end | |
describe '::static_method' do | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
static methods: