Easy way to detect whether rspec or cucumber is running?
问题 I'm currently checking in some places whether code is being executed in test mode, by Rails.env.test? I would like to go one step further, and check whether it is Cucumber or Rspec executing the code, in order to finetune some methods for i18n (which I do want to run differently in a Cucumber context, but not in an Rspec context) Is there any way to do this? 回答1: You can set RAILS_ENV=cucumber and then ask: Rails.env.cucumber? 回答2: I'm using the cucumber-rails gem, and with that at least you