Writing a test for IP addresses

I have a Rails controller which behaves differently based on the IP
address of the remote request. However, the defaults for functional
tests get submitted with an IP of How can I create a series of
tests that use various remote IP addresses per get?


@request.env['REMOTE_ADDR'] = '' # or whatever IP address

Do that in your setup before your test. Might be a more direct way,
but that's how I've been doing it.

Thanks, Jim – that’s exactly what I needed.