views:

105

answers:

1

I created a simple smoketest for a portal running java/tomcat/jahia (cms) fronted by cache servers and big ip. Cucumber + Webrat + Mechanize is a good fit for a simple smoketest of this setup. (and it has been very easy to get started).

Right now I have hardcoded into /features/support/paths.rb the following lines:

module NavigationHelpers
  #PATH="http://production-environment"
  #PATH="http://staging-environment"
  #PATH="http://test-environment"
  PATH="http://localhost:8080"

  #
  def path_to(page_name)
    case page_name

    when /the homepage/
      "#{PATH}/"
    when [...]
       ...

    end
  end
end

World(NavigationHelpers)

Right now I manually switch the comments when I want to test different environments. The issue here is I'd love to get rid of the constant PATH and put a default value inside one of the support files. And i also want to be able to feed cucumber with this environment variable from the command line like so:

cucumber ENV=staging

How do you cope with this issue? Any suggestions? Links to code that deals with this? Snippets?

+1  A: 

You can pass environment variables to Cucumber like you have done with ENV. Each environment vriable will then be available in Ruby's ENV constant. More details in the Wiki

(I just added this page - the feature has been around since 0.3.90 but was only ever mentioned in the History.txt file).

Thanks for your quick reply. I guess I still need to map something like `ENV=staging` to `http//staging-server/` or similar
Jesper Rønn-Jensen