Rails tutorial: undefined method

后端 未结 1 1332
囚心锁ツ
囚心锁ツ 2021-01-28 04:14

I\'m stuck (again!) at Chapter 9 (this time in section 9.2.2) of the Rails tutorial. I am getting

bundle exec rspec spec/
................................FFF...         


        
相关标签:
1条回答
  • 2021-01-28 04:33

    I finally found the culprit for the erratic test results that I have been observing in this case and, quite likely, on previous occasions (Failure/Error: sign_in user undefined method `sign_in', Rails named route not recognized). The problem seems to be that rails does not clear by default the cache between tests. Which is, actually, downright scary. It seems you cannot really trust the test results. I realised this by commenting out the method that rails was complaining about and re-running the test. The error persisted which meant one thing - rspec was simply working with some cached versions of the files and thus disregarding the changes which I am making. So even if the tests pass you can't be sure that they really do. This is really bizarre. After realising the problem with a bit of googling I found how to force rails to clean the cache - check jaustin's answer here: is Rails.cache purged between tests?

    0 讨论(0)
提交回复
热议问题