On Apr 18, 2011, at 10:58 PM, Zhong wrote: > Dear all, > > Anyone know how to pass command-line parameter to Rspec script? > > For example: > I want to run the test.rb script. Suppose there is a parameter that is > set in test.rb script is sleep. For the convenience,I want to set the > parameter for sleep in the command-line. > If type : $ spec test.rb --sleep 10 > The script will sleep 10 seconds. > If type $ spec test.rb --sleep 5 > The script will sleep 5 seconds. > > Anyone can describe the detail how to do that?
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) HTH, David _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users