scriptonia

Feb 10 '12

Enable localStorage for cucumber features

We have already made fork for capybara-webkit and now we can test localStorage features using cucumber/capybara-webkit.

But for enabling properly this feature you should use the next following snippet in the env.rb:


Capybara.default_host = "lvh.me"
Capybara.app_host = "http://lvh.me:3003"
Capybara.server_port = 3003

Before('@html5') do
  if [:webkit, :webkit_debug].include? Capybara.current_driver
    page.driver.browser.set_attribute("LocalStorageEnabled")

    # Single localStorage per scenario by generating subdomain
    part = (1000 * rand()).to_i.to_s
    Capybara.default_host = "subdomain#{part}.lvh.me"
    Capybara.app_host = "http://subdomain#{part}.lvh.me:3003"
  end
end

View comments Tags: rails cucumber capybara capybara-webkit html5

Blog comments powered by Disqus