Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to run RSpec examples in multiple environments. I want to pass a flag into RSpec that a case statement can key off so as to set the proper values. This is such a natural thing to want to do that I must be overlooking the obvious. Thank you for your help.

share|improve this question
Is this more of a programming question or a server question? I'm not sure what you're trying to accomplish. – Aaron Sep 27 '11 at 3:05
up vote 1 down vote accepted

It depends on how RSpec is invoked.

In general I'd avoid command-line parameters as every piece of the stack is always competing to read them in its own way, and the semantics are too loose (it's only sequence of character strings).

A simple and quite generic mechanism would be environment variables. Most execution contexts will allow you to set them easily, including continuous integration services and of course your shell.

% FOO=hop ruby -e "puts ENV['FOO']"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.