I'm creating a gem and this gem depends Rails is loaded. I need to create a scenario when Rails is not loaded. I have this code in my gem as an example:
if defined?(Rails) && Rails.application
#some code
end
I've tried to create a stub, but it seems Rails restarts the application method when we set it with nil. https://github.com/rails/rails/blob/fbe2433be6e052a1acac63c7faf287c52ed3c5ba/railties/lib/rails.rb#L38
Rails.stub(:application, nil) do
# test
end