Forked from Bartuz/rspec_model_testing_template.rb
Last active
March 1, 2017 08:47
-
-
Save xuncheng/ce84f94d9f8dca5a4cd1ed3e91f723f2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 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. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: | |
# | |
# rspec-rails: https://github.com/rspec/rspec-rails | |
# Shoulda-matchers: https://github.com/thoughtbot/shoulda-matchers | |
# shoulda-callback-matchers: https://github.com/beatrichartz/shoulda-callback-matchers | |
# factory_girl_rails: https://github.com/thoughtbot/factory_girl_rails | |
require 'spec_helper' | |
RSpec.describe Model do | |
context "associations" do | |
it { is_expected.to belong_to(:user) } | |
end | |
context "validations" do | |
it { is_expected.to validate_presence_of(:user_id) } | |
end | |
context "callbacks" do | |
it { is_expected.to callback(:generate_slug).before(:create) } | |
end | |
context "norton counters" do | |
it { is_expected.to respond_to(:submissions_count) } | |
end | |
context "norton timestamps" do | |
it { is_expected.to respond_to(:info_updated_at) } | |
end | |
describe ".class_methods" do | |
it "..." do | |
# ... | |
end | |
end | |
describe "#instance_methods" do | |
it "..." do | |
# ... | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment