How do I output a variable in a rspec test?

后端 未结 4 1176
说谎
说谎 2021-01-31 08:36

Is there a quick way to output the value of variable in a rspec test? Something like this for example, in a controller to output a variable, I do:

raise variable         


        
4条回答
  •  隐瞒了意图╮
    2021-01-31 08:48

    You can use the gem pry to do this

    1. add gem "pry" in your gemfile
    2. bundle install

    Now you can any test any variable by putting "binding.pry" just after that variable. Run bundle exec rspec filepath and you will get something like rails c, then write directly your variable.

    I hope it makes sense

提交回复
热议问题