Rails: How to stub the env in Rails 7+
Rails 7.1
added
Show archive.org snapshot
a new method Rails.env.local?
. If you want to stub the Rails env correctly, use ActiveSupport::EnvironmentInquirer
like this:
# check if the value of stubbed_env is valid
allow(Rails).to receive(:env).and_return(ActiveSupport::EnvironmentInquirer.new(stubbed_env.to_s))