From: sto.mar@... Date: 2012-07-11T00:16:08+09:00 Subject: Re: read and store definitions from an outer file Am 10.07.2012 15:34, schrieb firstsense sdasad: > Hi guys, I am a newcomer to Ruby, i got into it by having to make > testing scripts for my company. I have not had such problem that i > couldn't solve by reading, but now I encountered one. I have made some > test suites using watir gem which include definitons like user name and > test page address. But if i move to an other environment i have to > modify these for each test suite. What i would like to achieve: I would > like to have a single file(testreq.txt for example) containing these > definitions and I would like to make my test suites to read and store > these values from my testreq.txt file. Thank you very much for your help > in advance! > > Best wishes, > Alex > you could use YAML: require 'yaml' config_file = 'testreq.txt' config = {:name => 'User', :address => 'Address'} File.open(config_file, 'w') {|f| f.write(config.to_yaml) } # or: File.open(config_file, 'w') {|f| YAML.dump(config, f) } saved_config = YAML::load_file(config_file) puts "Name: #{saved_config[:name]}" #=> Name: User --