测试环境的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屋!
查看全文