How do I mock an OmniAuth hash using Rails and minitest?

这一生的挚爱 提交于 2019-12-01 09:24:29

The OmniAuth docs state

When you try to test the OmniAuth, you need to set two env variables

and provide examples using RSpec

before do
  Rails.application.env_config["devise.mapping"] = Devise.mappings[:user] # If using Devise
  Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:twitter]
end

In your case, it seems like you may need to set

Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:google]

in your setup_omniauth_mock method, after the call to OmniAuth.config.add_mock.

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