Stub a Rails Environment in RSpec
When writing tests to test for rails.env specific functions, in order to temporarily change the rails environment during testing, use this:
Rails.stub(env: ActiveSupport::StringInquirer.new("production"))
This will then pass when doing a
Rails.env.production?