I\'m using Rails 5 with minitest. I want to mock logging into my sessions controller, which relies on omniauth (I use Google and FB for login). I have this in my controlle
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
.