There is a much better way described here: https://stackoverflow.com/a/24052647/362378
it "should do something specific for production" do
allow(Rails).to receive(:env) { "production".inquiry }
#other assertions
end
This will provide all the functions like Rails.env.test?
and also works if you just compare the strings like Rails.env == 'production'