How do I test if the response of a controller action in Rails is a file? (rack-test or capybara)
Should I use unit tests to do it?
The scenario is simple: I have to test if the exported users from the database are the same contained in the generated .csv from an action.
You don’t need rack-test or Capybara to do this. The default test infrastructure is all you need. Simply check that the Content-Type is CSV:
If you want to take it one step further, you can parse the returned CSV to make sure it is valid and test the values returned: