Rails测试环境命名为Routes [英] Rails Test Environment Named Routes

查看:98
本文介绍了Rails测试环境命名为Routes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,当我运行测试(使用Rspec和spork,如果有关系的话)时,我的主机名设置为www.example.com.所以,如果我这样做:

I've noticed that when I run tests (using Rspec and spork, if that matters), my hostname is set to www.example.com. So if I do:

 visit sports_url

测试实际上是去www.example.com/sports.

the test is actually going to www.example.com/sports.

这是一个问题,因为我需要使用硒运行某些测试(以获得javascript支持).另外,我注意到我的电子邮件被标记为来自www.example.com.

This is a problem because I need to run some of the tests with selenium (to get javascript support). Also, I noticed my emails where being marked as coming from www.example.com.

我搞砸了什么?为什么测试环境以example.com的身份运行?我可以在某个地方配置它吗?我认为它应该是程序性的(取决于测试服务器在哪个端口上启动).

What did I mess up? Why is the test environment running as example.com? Can I configure this somewhere? I would assume it should be programatic (depending on what port the test server starts up on).

推荐答案

您可以配置测试环境域,然后设置DNS以执行所需的操作.

You can configure the test environment domain, then set up DNS to do what you need.

如何更改默认的"www.example.com"在Rails中进行测试的域?

这篇关于Rails测试环境命名为Routes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆