Search code examples
ruby-on-railstestingrspec-rails

Rails mock call FROM external web service?


I've seen a lot of posts of how to mock external service requests during tests to improve test suite's speed and make them functional even without connection using gems like Webmock or VCR.

Now I have a route that gets called FROM an external service. i.e the external service POSTs to my app. How could I mock that?


Solution

  • Now I have a route that gets called FROM an external service. i.e the external service POSTs to my app.

    This means your application provides a public API through one of your controller. To test the public API, you simply test the corresponding action in your controller as you always do when testing controllers.

    Here's a reference.