mha*_*190 3 facebook ruby-on-rails cucumber omniauth facebook-login
我按照本教程在我的网站上设置了Facebook登录,并使用黄瓜和水豚.我曾尝试以下其他SO帖子这样解释如何建立一个假的登录帐户.如果我直接使用它,我得到:
When I follow "sign_in" # features/step_definitions/web_steps.rb:56
No route matches [GET] "/oauth/authorize" (ActionController::RoutingError)
./features/step_definitions/web_steps.rb:57:in `/^(?:|I )follow "([^"]*)"$/'
features/facebook_signin.feature:9:in `When I follow "sign_in"'
Run Code Online (Sandbox Code Playgroud)
如果我添加get "/oauth/authorize"到我的路线,我得到:
When I follow "sign_in" # features/step_definitions/web_steps.rb:56
uninitialized constant OauthController (ActionController::RoutingError)
./features/step_definitions/web_steps.rb:57:in `/^(?:|I )follow "([^"]*)"$/'
features/facebook_signin.feature:9:in `When I follow "sign_in"'
Run Code Online (Sandbox Code Playgroud)
我不知道发生了什么,为什么抱怨.如果我将我的Gemfile更改gem 'omniauth-facebook', '1.4.0'为只是gem 'omniauth-facebook'我得到几乎相同的错误,除了代替:
/oauth/authorize我得到了/dialog/oauth,而不是uninitialized constant OauthController,我得到了uninitialized constant DialogController
最近有没有人成功设置黄瓜测试登录Facebook?
当我在localhost:3000并导航到localhost:3000/auth/facebook一切正常,我正在使用sessionsController,所以我不明白为什么在测试中,它试图使用这些oauthControllers或DialogueControllers.
我最近有同样的问题或非常类似的问题:
ActionController::RoutingError:
No route matches [GET] "/dialog/oauth"
Run Code Online (Sandbox Code Playgroud)
我已经采用了正确设置来自另一个项目的模拟响应的工作规范,并且很惊讶突然得到这个错误.
在经历了很多痛苦和痛苦之后,当我意识到我忘记将OmniAuth设置为使用测试模式时,我有一个重要的面孔:
# spec/rails_helper.rb
OmniAuth.config.test_mode = true
Run Code Online (Sandbox Code Playgroud)
这将导致OmniAuth短路,以便您可以通过以下方式设置auth响应:
OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new({
:provider => 'facebook',
:uid => '123545'
# etc.
})
Run Code Online (Sandbox Code Playgroud)
我认为错误是由于OmniAuth试图通过:developer在测试环境中使用策略来提供帮助,因此您不会被auth提供程序禁止.
请参阅https://github.com/intridea/omniauth/wiki/Integration-Testing.
| 归档时间: |
|
| 查看次数: |
859 次 |
| 最近记录: |