2013-02-07 29 views
2

我經歷邁克爾·哈特爾的railstutorial和第11章遇到了一些錯誤的RSpec 。Rails的Rspec的錯誤 - 未定義的局部變量或方法#<:: RSpec的核心:: ExampleGroup :: Nested_3:0 ...>

rspec error

我真的不知道什麼是錯誤消息指。

爲了以防萬一,這是我的規範代碼。

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 

任何幫助,將不勝感激。謝謝!

回答

3

改變這一行:

設(:關係){follower.relationships.build(followed_id: followed_id)}

let(:relationship) {follower.relationships.build(followed_id: followed.id)} 
+0

的感謝!那就是訣竅。還很不熟悉變量約定... – jeebface

相關問題