开发者

How to allow web requests when using VCR / WebMock? [closed]

开发者 https://www.devze.com 2023-03-23 16:35 出处:网络
开发者_运维知识库 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not
开发者_运维知识库 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

I'm currently using RSpec2, Cucumber and VCR (via WebMock), and everything's working great.

With VCR normally all requests are recorded and then replayed against the recorded cassettes.

Now I want to allow real web requests in some scenarios:

  • In Cucumber, I've setup a "live" profile which runs any test tagged with @live. For these tests – and these tests only – I'd like to allow real web requests.
  • I want from time to time run the tests against the real api and ignore the recordings


You can do this with cucumber's Before and After hooks. Just disable VCR using something like this:

Before('@live') do
  VCR.eject_cassette
  VCR.turn_off!
end

This may be dependent on exactly how you are integrating VCR with your cucumber tests though.

0

精彩评论

暂无评论...
验证码 换一张
取 消