Skip to content

Instantly share code, notes, and snippets.

@francirp
Created October 1, 2014 16:33
Show Gist options
  • Save francirp/4fad5018aef2b3a2aa9a to your computer and use it in GitHub Desktop.
Save francirp/4fad5018aef2b3a2aa9a to your computer and use it in GitHub Desktop.
Capybara Pow
# Switch Pow to For Cucumber Tests
# See following Stack Overflow doc for context:
# http://stackoverflow.com/questions/10685465/rails-cucumber-capybara-selenium-pow-domains-subdomains-and-javascript
pow_config = "#{Rails.root}/.powenv" # Dont change, this is the Config Files Location.
pow_config_stash = "#{Rails.root}/.powenv_original" # This is what the config will be stashed as during testing.
config.before do
# Set the default host
Capybara.app_host = "http://powder.dev"
# Stash the existing config
File.rename(pow_config,pow_config_stash) if File.exists? pow_config
# Write the new pow config
f = File.new("#{Rails.root}/.powenv", "w")
f.write "export RAILS_ENV=test"
f.close
# Touch tmp/restart.txt to force a restart
FileUtils.touch "#{Rails.root}/tmp/restart.txt"
end
config.after do
# Delete the temp config
File.delete(pow_config)
# Restore the Original Config
File.rename(pow_config_stash,pow_config) if File.exists? pow_config_stash
# Touch tmp/restart.txt to force a restart
FileUtils.touch "#{Rails.root}/tmp/restart.txt"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment