Created
October 13, 2011 12:02
-
-
Save commuterjoy/1284070 to your computer and use it in GitHub Desktop.
swap a port number when a cucumber scenario is tagged with varnish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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