mardi 13 décembre 2022

(Rails)Where should i define method that can use in Rspec and Controller?

I'm making method that can used in Rspec test and Controllers. But i don't know where to store it.

Here are options that i have thought.

  1. application_helper -> but this file is used for method which used in applicaion controller.

  2. spec_helper.rb

  3. rails_helper.rb -> these two file is for rspec test

where should i store it?

I read this article but i'm not using models.

How to make a custom method that can be used anywhere in rails app

Now i had stored it at application_helper.rb, and call as

ApplicationController.helpers.custom_method

Is this right practice?

Aucun commentaire:

Enregistrer un commentaire