0

I have a rails app with some rspec feature tests. This app Alice works in tandem with another program Bob

When i want to use Bob, i create a json file in a specific url with instructions in my Alice app. Bob then fetches this json file with HTTP get, does its function and use HTTP post to give the results back to Alice.

I want to use vcr to create http fixtures, how can i fake Bob's behavior in my tests ?

  • HTTP get on the json url
  • HTTP post with the results

Is it possible to tell vcr to wait for http requests ?

Sacha
  • 75
  • 5

1 Answers1

0

If you're talking about the proper testing of Alice in isolation (assuming Bob is working as expected) just create the fixtures for the desired Bob's payloads upfront and feed them to the appropriate Alice controllers' tests.

If you are talking about the proper integration test you should not stub the requests at all - for the proper integration tests Alice and Bob must communicate as they do in the production environment. Some hybrid (kind of) solutions might exist as well - for example, fake Bob-like service with bare minimum (test only) functionality inside Alice (https://thoughtbot.com/blog/how-to-stub-external-services-in-tests#create-a-fake-hello-sinatra)

Konstantin Strukov
  • 2,899
  • 1
  • 10
  • 14