circa75 Home | About circa75 | Articles | Links | Contact Us

Posted by aaron at 03:01PM, Sunday, November 02nd, 2008

Setting the client IP address in a Ruby on Rails integration test

This is here because either my google-fu is even worse than I thought, or there's no clear explanation of this on the web. Maybe next time I search for it I'll come across my own solution here!

If you need to set the client IP address in a request generated in a Rails integration test, just add a :remote_addr symbol/value pair to your headers hash, like:

get 'my_url', { :a_param => 'foo' }, { :remote_addr = '192.168.0.1' }

Obviously, for functional tests, you merely need to set the header in the request object.
circa75 Home | About circa75 | Articles | Links | Contact Us

All content copyright © 2001-2009 the owners of http://www.circa75.com/