如何为某些测试存根配置

问题描述 投票:-1回答:1

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

ruby-on-rails selenium rspec mocking stub
1个回答
1
投票

您可以在之前的块中存根:

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

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

© www.soinside.com 2019 - 2024. All rights reserved.