How do i access the stub_request from within Cucumber > VCR

306 views Asked by At

I would like to fake a network timeout in my cucumber step definition like so:

Given(/^the network is timing out$/) do
  stub_request(:any, 'www.example.com').to_raise(RestClient::GatewayTimeout)
end

It will give the error that stub_request does not exist.

So, my question is where to find the webmock object within VCS, so i can add a stub_request.

2

There are 2 answers

0
Jason On

in env.rb:

require 'webmock/cucumber'
0
Mischa Molhoek On

i ended up making a little library that makes it very easy to test arbitrary errors when accessing/testing url's in cucumber

https://github.com/mmolhoek/vcr-uri-catcher

grtz