All these experts be like test, AND THEN THEY MAKE IT HARD AS FUCK TO TEST...RSPEC AND SHOULDAMATCHERS AND FACTORYGIRL

All these experts tell you to test THEN THEY MAKE IT HARD AS FUCK TO SET UP AND MAKE YOUR FIRST TEST. FUCK YOU.

FactoryGirl Rspec Setup Requirements

# Gemfile
group :development, :test do
  gem 'rspec-rails'
  gem "factory_girl_rails"
end

$ rails generate rspec:install

# add this to your spec/rails_helper.rb
require 'factory_girl'
include FactoryGirl::Syntax::Methods

ShouldaMatcher Setup Requirements

Yea, it’s annoying. You gotta configure this shit for it to work. They’re trying to be language agnostic (IE SUPPORT THE ENTIRE WORLD), but that makes it way more difficult to install this shit and get it working. https://github.com/thoughtbot/shoulda-matchers

#Gemfile
group :test do
  gem 'shoulda-matchers', '~> 3.1'
end

# Add the following to spec/rails_helper.rb
require 'shoulda/matchers'
Shoulda::Matchers.configure do |config|
  config.integrate do |with|
    # Choose a test framework:
    with.test_framework :rspec
    with.test_framework :minitest
    with.test_framework :minitest_4
    with.test_framework :test_unit

    # Choose one or more libraries:
    with.library :active_record
    with.library :active_model
    with.library :action_controller
    # Or, choose the following (which implies all of the above):
    with.library :rails
  end
end

Then in your spec file you can do shit like this…

require 'rails_helper'

RSpec.describe Reminder, type: :model do
  it { should validate_presence_of(:phone_number)  }
  it { should validate_uniqueness_of(:phone_number) }
end

Post Content