Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何禁用用于Capybara测试的webmock?_Ruby On Rails_Capybara - Fatal编程技术网

Ruby on rails 如何禁用用于Capybara测试的webmock?

Ruby on rails 如何禁用用于Capybara测试的webmock?,ruby-on-rails,capybara,Ruby On Rails,Capybara,我正在使用webmock和VCR进行一些基本的Rspec测试,但我想在验收测试中禁用webmock,这样我就可以实际发出外部HTTP请求 最好的方法是什么?来自: 你可以这么做 before do VCR.turn_off! WebMock.allow_net_connect! end after do VCR.turn_on! WebMock.disable_net_connect! end 您可能只想在某些gem组中使用webmock,而不想在testgem组中使用 be

我正在使用webmock和VCR进行一些基本的Rspec测试,但我想在验收测试中禁用webmock,这样我就可以实际发出外部HTTP请求

最好的方法是什么?

来自:

你可以这么做

before do
  VCR.turn_off!
  WebMock.allow_net_connect!
end

after do
  VCR.turn_on!
  WebMock.disable_net_connect!
end

您可能只想在某些gem组中使用
webmock
,而不想在
test
gem组中使用
before do
  VCR.turn_off!
  WebMock.allow_net_connect!
end

after do
  VCR.turn_on!
  WebMock.disable_net_connect!
end