Q: rails don't calls the engine's controller I am trying to define some helper methods to be used in the app's controller, but it seems that rails don't even call the controller. just for the test I have the following controller in my app/controllers/my_engine/application_controller.rb and as the documents say rails should find it first and an error should raise because THIS_SHOULD_PRODUCE_ERROR is unknown, but the rspec happily executing without any errors!
class ApplicationController <  ActionController::Base
  THIS_SHOULD_PRODUCE_ERROR
end

I even tried to mimic the devise's way but the results are the same!

A: The guide section on the app directory suggests that the application_controller in an engine "will provide any common functionality for the controllers of the engine".
So I wouldn't expect that any additions to that controller will be available to all controllers in an application.
That also means that your application_controller is, I suspect, not getting called when you're running your test. Which would explain why you're not seeing an error.

In terms of how devise does it I think you need to be looking at how define_helpers works. The code you've linked to in your question is the application controller in the test app for the devise gem.

A: I noticed that I have got things wrong, and the application_controller in the engine does not get applied to application_controller in the app! Also,   I couldn't figure out how the devise did it, but I have come up with the simple workaround for this:
require_relative 'controllers/helpers'

module Acu
  module Injectors
    class << self

      ActiveSupport::Notifications.subscribe "start_processing.action_controller" do |**args|
        eval((Acu::Configs.get :base_controller).to_s).class_eval do
          include Acu::Controllers::Helpers
        end
      end

    end
  end
end

This will inject controller helpers to the user's base controller (which I get from the user, default: :ApplicationController) at the end of the class, which is perfect for me (but don't know how to add it to begging of the class if anyone needs it)
