mercredi 8 juillet 2015

Rails, how to create functional tests for apis using minitest

I have a rails app that has api controllers for providing restful api. The api controllers are located at app/controllers/api/v1/controllers.rb

Say I have a controller called tweets_controller.rb, its in app/controllers/api/v1/tweets_controller.rb, Besides the api controller, I also have a tweets_controller for the web server, in app/controllers/tweets_controller.rb. According to the rails testing guide, I know how to create tests for web server's tweets_controller in test/controllers/tweets_controller_test.rb, but how can I create tests for the api controllers?

I tried create the file test/controllers/api/v1/tweets_controllers_test.rb but when I ran the test, an error occured said

Don't know how to build task '/test/controllers/api/v1/tweets_controller_test.rb'.

I searched on the web and most of the results are about RSpec, I want to learn how to minitest before move to RSpec.

Aucun commentaire:

Enregistrer un commentaire