2017-06-16 40 views
0

我得到的一個問題Rspec的推出rspec的時候未定義局部變量或方法`matcher_name」

Failure/Error: 
     expect { 
     post :create, params: {tag: attributes_for(:tag)} 
     }.to change(Tag, :count).by(1) 

    NameError: 
     undefined local variable or method `matcher_name' for #<RSpec::Matchers::BuiltIn::Change:0x000000094f7348> 
     Did you mean? match_unless_raises 

編輯:

它,只有當我做

rspec 

,而不是

發生
bundle exec rspec 

回答

1

始終使用bundle exec與項目相關的二進制文件之間的差異。沒有它,錯誤的版本可能會被收回。覈實。

rspec --version 
bundle exec rspec --version 
1

控制檯錯誤日誌說可能你提供了錯誤的方法名稱,很明顯。你可以嘗試改變你使用的方法或變量的名字嗎?

您也可以參考此爲獲得這兩個命令 bundle exec rspec VS rspec spec

+0

「這很明確」 - 除了方法名無處可見。這是如何清楚的? –

相關問題