Я думаю, что проблема с построением моей пользовательской фабрики. Я получаю сообщение об ошибке, в котором говорится, что пароль не может быть пустым, но он явно указан в моем файле factoryies.rb. Кто-нибудь видит что-нибудь, чего мне не хватает? Или причина того, почему спецификация не работает? Я делаю очень похожую вещь для одной из моих других моделей, и, похоже, она успешна. Я не уверен, вызвана ли ошибка разработкой или нет.
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)>'
Factory.define :user do |user|
user.name "Test User"
user.email "user@example.com"
user.password "password"
user.password_confirmation "password"
end
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
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