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.
Asked
Active
Viewed 44 times
1 Answers
1
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']"
hop

Pierre Carrier
- 2,617
- 18
- 28