I think this question answered before. You can search archives. But I
added this to wiki FAQ. I also give wiki text here.

Q. What I'd like to do, is to have a configuration file (eg.
config.txt), which would have a number of key/value pairs, such as
"UserName=user", which would be read by a test script to, for example,
log into a page.

A.  You can use ruby file for this. i.e
$user_name = 'atilla'
$last_name = 'ozgur'

save this as initialValues.rb

then in your script you can require initialValues.rb classes and
variables is ready for your use. Do not forget that these are global
variables. Maybe a class and class variables would be more suitable
for this. They will be more encapsulated in that way.

class initialValues
  @@user_name = 'atilla'
  @@last_name = 'ozgur'

end

Note: A variable prefixed with two at signs is a class variable,
accessible within both instance and class methods of the class.

Then you can use them as.

initialValues.user_name
initialValues.last_name

this way, related values will have their place.

_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to