I have a controller for my users:
class API::V1::UsersController < ApplicationController
respond_to :json
def create
@user = User.create(user_params)
respond_with(:api, :v1, @user)
end
end`
I'm using the responders gem.
When I run my RSpec tests, I get a 422 error. Here is the failing test:
describe "POST create" do
it "should create a user" do
post :create, user: FactoryGirl.build(:user).attributes, format: :json
expect(response.status).to eq(201)
end
end
- I'm using has_secure_password on my user model.
- I have password and password_confirmation in my user_params (strong parameters)
- My factory has matching password and password_confirmation
FactoryGirl.define do factory :user do first_name Faker::Name.first_name last_name Faker::Name.last_name email Faker::Internet.safe_email password "123456789" password_confirmation "123456789" date_of_birth 25.years.ago end end
Anything I'm missing or should look for?