尝试使用RSpec测试OmniAuth时出现“禁用了真实HTTP连接”错误

 huanghunlaoren_619 发布于 2023-02-12 09:53

我一直在尝试用RSpec测试OmniAuth,但是它没有用。

spec_helper.rb

OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:twitter, {:uid => '12345'})

和在 spec/requests/static_pages_spec.rb

describe "for signed-in users" do
  before do
    visit "auth/twitter"
  end
  it { should have_content("Log out") }
end

而且我得到以下错误。

 Failure/Error: visit "auth/twitter"
 ActionView::Template::Error:
   Real HTTP connections are disabled. Unregistered request: 

根据正式文件的要求,auth/twitter应重定向到auth/twitter/callback。为什么尝试建立HTTP连接?

我已经阅读了以下网页和问题,但无法找到测试失败的原因。

http://blog.zerosum.org/2011/03/19/easy-rails-outh-integration-testing.html https://github.com/intridea/omniauth/wiki/Integration-Testing omn​​iauth-facebook并使用rspec http://blog.plataformatec.com.br/2010/12/acceptance-tests-for-omniauth/

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有