Sometimes you need a piece of code to do something different for specs than for features. If you don't have separate environments, you can't check your Rails.env
.
I managed to distinguish between specs and features by asking Capybara
.
Note that this only works when you do not use Capybara in specs.
if defined?(Capybara) and Capybara.respond_to?(:current_driver)
# you're in a Cucumber scenario
else
# you're probably in a spec
end
You could omit the defined?(Capybara)
condition, if you are sure that Capybara
is always defined when that code is being called.
Posted by Arne Hartherz to makandra dev (2013-05-08 13:59)