I suppose by running offline you mean, run it via code in the rails console, or some sort of lib or model.
You can access a controller information using the following command:
This will create a new session (similar to integration tests session), where you can perform requests to the rails application.
You perform a request to your action/controller in the following manner:
To capture the ouput, you can use the value store in
session.response and if you want to get the body, you can use:
Let's say you have the following controller:
class TestsController < ApplicationController
@name = 'Test'
and the following view:
Hi <%= @name %>
the following routes:
resources :tests, only: :index
you can create the following file:
session = ActionDispatch::Integration::Session.new(Rails.application)
path = Rails.application.routes.url_helpers.tests_path
and run it via:
rails runner run.rb, you should get 'Test'