lundi 29 janvier 2018

How do I load a custom module in Rails minitest?

On Rails 5.1, I have this module:

app/datatables/financing/merchants_datatable.rb

and in my merchants_controller.rb file, I have this code:

def index
    ...
    respond_to do |format|
        format.html
        format.json { render json: Datatables::Financing::MerchantsDatatable.new(view_context) }
    end
end

When I try to run my test/controllers/merchants_controller_test.rb, I run into this error:

NameError: uninitialized constant Financing::MerchantsController::Datatables

How can I load my merchants_datatable.rb module in my tests?

Thanks!

Aucun commentaire:

Enregistrer un commentaire