我正在阅读迈克尔·哈特尔(Michael Hartl)铁道教程的第11章,并且遇到了一些rspec错误。
我不确定错误信息的含义。
以防万一,这是我的规范代码。
let(:follower) {FactoryGirl.create(:user)}
let(:followed) {FactoryGirl.create(:user)}
let(:relationship) {follower.relationships.build(followed_id: followed_id)}
subject {relationship}
it {should be_valid}
describe "accessible attributes" do
it "should not allow access to follower_id" do
expect do
Relationship.new(follower_id: follower_id)
end.to raise_error(ActiveModel::MassAssignmentSecurity::Error)
end
end
任何帮助将不胜感激。谢谢!
答案 0 :(得分:3)
更改此行:
let(:relationship){follower.relationships.build(follow_id: followed_id)}
要
let(:relationship) {follower.relationships.build(followed_id: followed.id)}