road242 road242 - 2 years ago 109
Ruby Question

Check on TEST mode during runtime

My web application writes some kind of log during runtime.
I don't want to write this log when running my test suite using cucumber.

So, how can I check my current runtime environment (TEST, DEV or PROD)?

I'm looking for the C equivalent to i.e. :

#ifdef DEBUG

   // just run in debug mode


Thank you very much for helping me on this.

Answer Source

Try this for the if condition:

if ENV['RAILS_ENV'] == "test"
    # Insert Code Here

(replace 'test' with 'development' or 'production' as needed)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download