【发布时间】:2026-01-03 14:30:01
【问题描述】:
我使用 rails 4.1.4 和 fakefs 0.5.2。 我尝试升级到 rails 4.2.0,但现在我的测试因以下错误而失败:
Errno::ENOENT:
No such file or directory @ rb_sysopen - https://google.com/
我尝试搜索,最后发现这可能是由 FakeFS 引起的,因为当我在 Rails 控制台中调用 open 时,它按预期工作,如下所示:
2.1.0 :001 > link = open("https://google.com")
=> #<Tempfile:/tmp/open-uri20150227-21959-18cqr0h>
2.1.0 :003 > require 'fakefs/spec_helpers'
=> true
2.1.0 :004 > FakeFS.activate!
=> true
2.1.0 :005 > link = open("https://google.com")
Errno::ENOENT: No such file or directory - https://google.com
有人知道这是什么原因吗?
更新: 所以,我最终决定做的是用curb 替换open-uri。还有其他选择,例如rest-client 和Net::HTTP。 谢谢
【问题讨论】: