如何为某些测试存根配置

How to stub a configuration for some tests

我在 test.rb 文件中有 config.iafis_soap_enabled = false。在某些情况下我希望它是true,我该如何存根它?

您可以将其存入 before 块中:

before do
  allow(Rails.application.config).to receive(:iafis_soap_enabled).and_return(true)
end

由于您正在对方法调用进行存根,因此无需在后块中将值重置为 false