2
votes

We have application which uses REST API service as backend. Hence we do not need database at our end. Now I stuck with testing the controller as by default it needs database to load the fixtures and then runs the test. Any one have any idea how to test the controller with Minitest and without database. Is there any other testing framework I can use to test the controllers?

Rails version 4.2.1 and ruby 2.2.1.

Thanks in advance.

2
Have you looked into RSpec's mocks and FactoryGirl?Catherine Cai
I resolved this issue by including test helpers separately instead of including rails/test_help.Vishakha

2 Answers

1
votes

The VCR gem allows you to make an API call and record the response, which will allow you to ping your backend API and test whatever it sends over. It shouldn't require a database as you're running tests against the cassette (which is the recorded response, rather than anything actually in the database).

1
votes

I resolved this issue by including test helpers separately instead of including rails/test_help.