Rspec and Rails 4, update skip callback

血红的双手。 提交于 2019-11-28 01:46:34

Since you did not mentioned your ruby version I'll assume it's 2.

First of all you need to learn how to properly debug your code in order to fix the issues yourself.

Here is what you have to do:

1.Add pry gem to your app, pry-byebug there is also a version for ruby 1.9.3.

2.Add a break point in your code

it "updates the lodging and destroy the price" do
  (...) # Code here.

  binding.pry # The debugger  will open a console at this point   

  (...) # Maybe more code here
end

3.Verify all the variable and their values and see where the problem lies

In case you could not find the issue with binding.pry in your rspec file before the expect add it to after the first line of the method, and you can step through the debugger by typing next in the console opened by pry (it will be where your rails server is runnig). If that still does not help, try and add a binding.pry in your classes and see what is the state in there.

Spend a few minutes/hours now to learn debugging and it will save you days/weeks in long term. (while you are learning you don't really know how a program should behave and that extra knowledge is priceless, after a while you only need a debugger for extremely complicated issues).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!