How to change the environment variable of rails in testing
Rspec 3 onwards you can do
it "should do something specific for production" do allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("production")) #other assertions end