2

我正在阅读 Michael Hartl 的 railstutorial 的第 11 章,并且遇到了一些 rspec 错误。

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

任何帮助,将不胜感激。谢谢!

4

1 回答 1

3

更改此行:

让(:关系){follower.relationships.build(followed_id:followed_id)}

let(:relationship) {follower.relationships.build(followed_id: followed.id)}
于 2013-02-07T09:15:56.680 回答