Test integration between two rails apps

2019-07-20 12:44发布

问题:

I am developing a system composed of two different rails applications (server and client) which communicate via rest web services.

I have tests for each app individually, but I would like to add some test for the integration between the two platforms, to assert that one creates a request compatible with what the other is expecting.

Any hints would be appreciated.

回答1:

I have a similar architecture and we are using VCR in order to record all server side responses and avoid make requests always. It could turn annoying and right now I'm looking for a way to clean data from server after every request

I think VCR could be a good start point in order to test integration between your apps.

You can find documentation here -> Relish Docs



回答2:

I think there could be several approaches here, depending what you have implemented..

  1. If the client Rails app has user interface, try to write Selenium tests to perform the integration test in your local dev environment or a staging environment that has both deployed. (not ideal if the interface is still a prototype, changing frequently...)

  2. Maybe part of the client can be written as a Ruby gem (e.g. the communication rest api is a ruby gem). When the server app in testing environment, the server Rails app can use the Client gem to run integration test, i.e. call the module function, the same function is used by client. The client Rails app can also use the gem to make requests to the server. Here's a good guide to start migrating some of your reusable code to rubygem.