We have a Rails App and a Sinatra API with separate codebases. They need to work together with the same database.
We can create a record using the API, and then display a page for that record using the Rails app. When creating the record using the API, there are many other records that need to be created at the same time. This all happens fine on the Rails app.
Here’s the problem: What is the best way to test that when the API creates the record, all the other records are created and the page renders properly on the Rails app?
I am writing a test in the Rails app for this. Since the API is separate from the Rails app, I can create a mock. But the mock needs to do everything the API would do, so it is not really a mock.
Is it possible (or practical) to include in the Rails app the API file that contains the call to create the record?
Or is there a better way to test for this?
Well, you have two web applications. That is, two applications that expose a (more or less) public interface on the Net and that respond to HTTP calls.
Why do not use a HTTP client to invoke all of the two servers and perform a complete test (a “workflow test”, if you like)?
You can probably use any existing web testing tool for this, or write a test script with any language.