How can I set the request IP in a Capybara feature spec?

Viewed 1205

I am using RSpec and Capybara for my feature specs on my Rails 5.1 app. I want to fake the request IP to '1.2.3.4' for a single spec.

I've tried the following with Poltergeist...

before do
  page.driver.add_headers 'REMOTE_HOST' => '1.2.3.4'
end

However, placing a pry in my controller I see that request.headers['REMOTE_HOST'] is 127.0.0.1.

1 Answers
Related