I would like to be able to know that my code is run under rspec or not. Is this possible?
The reason is that I am loading some error loggers that would be cluttered with deliberate errors (expect{x}.to raise_error
) during testing.
I have looked at my ENV
variable, and there is no (apparent) signs of a test environment variable.
Add at the beginning of your spec_helper.rb
:
ENV['RACK_ENV'] = 'test'
Now you can check in your code whether the RACK_ENV
is test or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With