tags:

views:

29

answers:

1

I've written an rspec test using Watir against a web application and it's running fine. However, I now want to be able to run this test against the web application running on different domain names.

My initial thought was that I'd be able to pass a value to spec at the command line to set a variable within my script, but I can't see any easy method of doing this. So my second thought was that I might need to add an array of domains into my script and have it test all of them - but I don't always want to test every domain, and the domains are constantly changing as we add and remove sites to be tested.

What are my options for allowing the choice of targets I want?

+1  A: 

You can set an environment variable, as those get passed on. RSpec uses this for its rake tasks, btw.

In you're spec you can do something like:

before { @host = ENV['TARGET'] || 'default_target.com' }

You can run it like this:

TARGET=google.com spec .

Or:

TARGET=stackoverflow.com rake spec
Konstantin Haase
Also, if this is a bigger project you could place the ENV handling inside your spec_helper.rb
Konstantin Haase