Skip to content

Instantly share code, notes, and snippets.

@tellodaniel
Last active November 17, 2022 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tellodaniel/dff0ef8580d7f4b6a85ecf41fdd24999 to your computer and use it in GitHub Desktop.
Save tellodaniel/dff0ef8580d7f4b6a85ecf41fdd24999 to your computer and use it in GitHub Desktop.
Tello model cheatsheet
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
@omarandstuff
Copy link

static methods:

  describe '::method' do
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment