【发布时间】:2019-01-16 11:30:05
【问题描述】:
我已将以下代码放入我的config/environments/test.rb 文件中:
config.action_mailer.default_url_options = { :host => "localhost:3000" }
但是,当我运行测试时,所有路由都使用http://test.host。我正在尝试使用不接受 http://test.host 作为有效回调 URI 的 API,因此我需要更改它以正确接收 API 响应。知道为什么这不起作用吗? (我在我的测试套件中使用 RSpec、Guard 和 Spork)。
编辑:可能相关 - 这是在控制器规范中完成的。
EDIT2:似乎在通过get、post等发出请求后会发生变化。在测试中运行以下代码:
Rails.logger.debug users_url
get 'http://google.com'
Rails.logger.debug users_url
将产生以下输出:
http://localhost:3000/users
...get request related response here
http://google.com/users
【问题讨论】:
标签: ruby-on-rails-3 testing rspec