Created
November 23, 2016 13:29
-
-
Save tombruijn/aad6b4892df0a8a7c7420f76dfeeec0a to your computer and use it in GitHub Desktop.
Fake an ip address on a capybara request
This file contains 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
around do |example| | |
# Set custom IP address | |
original_app = Capybara.app | |
Capybara.app = lambda do |env| | |
Rails.application.call(env.merge("REMOTE_ADDR" => "8.8.8.8")) | |
end | |
example.run | |
Capybara.app = original_app | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment