测试环境的 Rails 端口 [英] Rails port of testing environment
本文介绍了测试环境的 Rails 端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用 Faraday 和 RSpec 测试我们的 Rails 应用程序的 HTTP API.Faraday 需要主机 url + 端口.不幸的是,测试环境的端口总是在变化.如何在规范中以编程方式访问当前端口?
I'd like to test the HTTP API of our Rails app using Faraday and RSpec. Faraday needs the host url + port. Unfortunately the port of the testing environment does always change. How do I access the current port programmatically in the spec?
推荐答案
如果使用 Capybara,您可以像这样在 spec_helper.rb 中设置端口:
If using Capybara you can set the port in the spec_helper.rb like so:
Capybara.server_port = 1234
另见:https://github.com/jnicklas/capybara/pull/123一个>
这篇关于测试环境的 Rails 端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文