I think there is a problem with my user factory being built. I'm getting an error saying that the password cannot be blank, but it's clearly set in my factories.rb. Does anyone see anything that I may be missing? Or a reason as to why the spec is failing? I do a very similar thing for one of my other models, and it seems to be successful. I'm not sure if the error is being caused by devise or not.
Rspec Error
User should create a new instance of a user given valid attributes
Failure/Error: User.create!(@user.attributes)
ActiveRecord::RecordInvalid:
Validation failed: Password can't be blank
# ./spec/models/user_spec.rb:28:in `block (2 levels) in <top (required)>'
Factories.rb
Factory.define :user do |user|
user.name "Test User"
user.email "[email protected]"
user.password "password"
user.password_confirmation "password"
end
user_spec.rb
require 'spec_helper'
describe User do
before(:each) do
@user = Factory.build(:user)
end
it "should create a new instance of a user given valid attributes" do
User.create!(@user.attributes)
end
end
user.rb
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
end