Skip to content

Instantly share code, notes, and snippets.

View dbarrionuevo's full-sized avatar

Darío Barrionuevo dbarrionuevo

  • San Miguel de Tucumán
View GitHub Profile
@dbarrionuevo
dbarrionuevo / rspec_model_testing_template.rb
Last active July 27, 2017 16:38 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails.
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
describe Model do
# Lazily loaded to ensure it's only used when it's needed
# Try to avoid @instance_variables if possible. They're slow.
let(:factory_instance) { build(:some_factory) }
describe 'ActiveRecord validations' do