RSpec spec_helper access to session variable

梦想的初衷 提交于 2019-12-22 04:45:11

问题


I am new to RoR and Rspec. I am trying to write Rspec tests for a home controller with tests for login and logout etc. I want to be able to login/logout a user using methods from the spec_helper.rb

However when I look at the spec_helper.rb it says it cannot find the session variable or methods like post. Why is this?

Apologies if the question is a little ambiguous. I am not very sure how to frame this problem.

Thanks


回答1:


In RSpec, you can just use:

session[:key]

However I would suggest reading RSpec.Info: Controllers and watching this Railscast.



来源:https://stackoverflow.com/questions/5481445/rspec-spec-helper-access-to-session-variable

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