【发布时间】:2016-02-04 09:38:30
【问题描述】:
有没有办法在 capybara 功能测试中检索提交的参数?
rspec 测试如下所示:
it 'can visit the next page' do
visit root_path
click 'form submit'
# here I'd like to access the last request for debugging purposes
end
由于封装,通常我不会在功能测试级别访问请求。有没有办法访问它?
【问题讨论】:
-
查看日志可能更容易。
tail -f logs/test.log -
@max 是对的。我认为您可以在测试中访问 request 对象。因此,您可以使用此对象有权访问的方法。
-
如果使用日志对您不起作用,您可能需要使用 pry 或 byebug 从控制器访问请求对象。可能可以修改 rspec 内部并提取请求,但这肯定要简单得多。
-
@max 我同意。
Request对象有所有方法,有人想要检查的东西。
标签: ruby-on-rails rspec capybara integration-testing rspec-rails