Peter Nixey
Peter Nixey

Reputation: 16565

Is it possible to set an environment variable in Cucumber?

I am building a web application that has a whitelabel option.

The whitelabel option offers all of the same functionality of the core website but is based off a different domain. When on that domain, a number of different templates and rules are applied to the site to account for the whitelabel features.

I would like to run almost all of my features on both the core domain and the whitelabel domain. How can I set an environment variable in Cucumber (ideally via the command line) so that I can rerun these critical tests based off the new domain?

Upvotes: 4

Views: 4787

Answers (1)

AlistairH
AlistairH

Reputation: 3229

You can do it via the command line like this:

bundle exec cucumber features DOMAIN=somedomain.local

You can then access this in ruby, for example in your env.rb file, like this:

if ENV['DOMAIN']
  # set features to run against the appropriate domain
end

Upvotes: 4

Related Questions