1

I'm converting the in-browser tests for an app to use the SitePrism gem. In the gem readme, I see the following:

A page usually has a URL. If you want to be able to navigate to a page, you'll need to set its URL. Here's how:

    class Home < SitePrism::Page
      set_url "http://www.google.com"
    end

If you've set Capybara's app_host then you can set the URL as follows:

    class Home < SitePrism::Page
      set_url "/home.htm"
    end

I anticipate needing to run these tests in multiple environments (i.e. locally, and on a staging server). I'm wondering how I would call Capybara's app_host method dynamically. Would I add something like this to my spec_helper file?

Capybara.app_host = ENV[URL]

Thanks.

Richie Thomas
  • 3,073
  • 4
  • 32
  • 55

1 Answers1

1

I'd do it in rails_helper, after loading the environment, eg:

case Rails.env
when "test"
  # use default
when "staging"
  Capybara.app_host = "http://www.google.com"
else
  raise "could not set app_host for environment: #{Rails.env}"
end
zetetic
  • 47,184
  • 10
  • 111
  • 119