开发者

Rails - How to simply mock current_user (OmniAuth) on Test::Unit?

开发者 https://www.devze.com 2023-03-01 14:46 出处:网络
I am trying to开发者_运维技巧 figure out how can I mock (simply) current_user inside my unit tests in Rails? (I am using Test::Unit). I tried to look on Google and StackOverflow but nothing really hel

I am trying to开发者_运维技巧 figure out how can I mock (simply) current_user inside my unit tests in Rails? (I am using Test::Unit). I tried to look on Google and StackOverflow but nothing really helpful!

Any ideas?

Thanks!


If you're in a unit test then you should probably be passing in current_user to your process. When testing from a higher level where you will actually care about current_user, OmniAuth has some mocking for tests.

Look Here: https://github.com/intridea/omniauth/wiki/Integration-Testing

Hope that helps.

0

精彩评论

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