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!
If you have complex config needs, try serialising data structures to and from Yaml.
Jams
···
On Jul 10, 2012, at 7:34 AM, firstsense sdasad <lists@ruby-forum.com> wrote:
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!
saved_config = YAML::load_file(config_file)
puts "Name: #{saved_config[:name]}" #=> Name: User
···
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!
Using a Module as Jam suggested is probably the simplest way.
But of course there are also many data formats you can use. I actually
prefer JSON over YAML, because it's simpler and more "robust". Reading
and writing works pretty much like with YAML:
Using a Module as Jam suggested is probably the simplest way.
But of course there are also many data formats you can use. I actually
prefer JSON over YAML, because it's simpler and more "robust". Reading
and writing works pretty much like with YAML: