[英]Setting consider_all_requests_local temporarily for rspec testing rails
I have some custom 404 and 500 pages I want to test, but I need Rails.application.config.consider_all_requests_local to be false for feature testing temporarily, and then turn it back on after the test is complete so that other tests can see the stack trace if they fail during testing. 我有一些我要测试的自定义404和500页面,但我需要暂时将Rails.application.config.consider_all_requests_local设置为false,然后在测试完成后重新打开,以便其他测试可以看到堆栈如果他们在测试过程中失败了。 Is there any way of doing so or is there possibly another solution to achieve what I'm looking for?
有没有办法这样做,还是可能有另一种解决方案来实现我正在寻找的东西?
For reference I am using Capybara and selenium-chrome to test. 作为参考,我使用Capybara和selenium-chrome进行测试。
You can set and the reset consider_all_requests_local
in before/after blocks: 您可以设置和重置
consider_all_requests_local
之前/块之后:
describe 'my awesome test' do
before do
Rails.application.config.consider_all_requests_local = false
end
after do
Rails.application.config.consider_all_requests_local = true
end
it 'does something magical' do
# some tests
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.