这是我的规格:
require 'spec_helper'
describe "User pages" do
let(:user) { FactoryGirl.create(:user) }
subject { page }
describe "for non-signed-in user" do
describe "profile page" do
before do
visit user_path(user)
end
it { should have_content("Sign in") }
it { should have_title("Sign in") }
end
end
end
这是factories.rb:
FactoryGirl.define do
factory :user do
sequence(:name) { |n| "User #{n}" }
sequence(:email) { |n| "user_#{n}@example.com" }
sequence(:callsign) { |n| "user_#{n}" }
password "foobar"
password_confirmation "foobar"
factory :admin do
admin true
end
end
end
我不断收到此错误消息:
非登录用户个人资料页面的用户页面
失败/错误:让(:user){FactoryGirl.create(:user)}
的ActiveRecord :: RecordInvalid:
验证失败:呼号不能为空,呼号无效
我很困惑。当我在factory.rb中设置呼号时,为什么会抱怨呼号是空白的?
答案 0 :(得分:0)