1

I have an RSpec script that tests a program in a different language I am developing. Since I can run and test 32 and 64-bit versions of this application, I would like to have a way to signal this on the command-line.

What I really want is to do something like this:

rspec -c myspec.rb lin32

or

rspec -c myspec.rb lin64

and have the lin32 or lin64 be passed as a string I can access in the ruby file itself. Is this possible? This site mentions environment variables but that is cumbersome. It also mentioned doing ARGV manipulation -- is this a possible way of doing it?

wickedchicken
  • 4,553
  • 5
  • 22
  • 28

2 Answers2

6

From David Chelimsky

You can't pass arbitrary arguments to the rspec command, but you can set an environment variable like this:

SLEEP=10 rspec test.rb 

Then within the script, the value of ENV["SLEEP"] is "10", so you can say:

sleep(ENV["SLEEP"].to_f) 
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Steve
  • 836
  • 11
  • 14
0

Try the -- parameter. It's used to tell an app to stop processing parameters and pass the remaining ones to a child process. I don't know if rspec understands it but it's worth a try.

`rspec -c myspec.rb -- lin32`
`rspec -c myspec.rb -- lin64`
the Tin Man
  • 158,662
  • 42
  • 215
  • 303