Skip to content

Instantly share code, notes, and snippets.

@commuterjoy
Created October 13, 2011 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save commuterjoy/1284070 to your computer and use it in GitHub Desktop.
Save commuterjoy/1284070 to your computer and use it in GitHub Desktop.
swap a port number when a cucumber scenario is tagged with varnish
# Cucumber has a nice feature where it can wrap code _around_ a
# scenario. In my case I have a Varnish cache running on port 6081
# and an plain apache on port 80 and various tests that rely
# on both services. So this way I can temporarily monkey patch the
# Capybara host if I tag any feature with '@varnish' and have the
# http traffic hit the cache.
Around('@varnish') do |scenario, block|
default_host = Capybara.default_host
Capybara.default_host = Capybara.default_host.gsub(/(:\d+)$/, ':6081')
block.call # run the scenario
Capybara.default_host = default_host # put it back
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment