开发者

RSpec spec_helper access to session variable

开发者 https://www.devze.com 2023-02-21 05:08 出处:网络
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

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 a开发者_高级运维m not very sure how to frame this problem.

Thanks


In RSpec, you can just use:

session[:key]

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号