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

この行を変更します。

let(:relationship){follower.relationships.build(followed_id:followed_id)}

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