开发者

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

#endif

Thank you very much for helping me开发者_开发百科 on this.


Try this for the if condition:

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

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


You can do following

Rails.env.test?
Rails.env.development?
Rails.env.production?

This will return true or false according to the runtime environment

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜