Re: Mocking request.remote_ip for testing.

Clem Rock
Thu, 27 Sep 2007 15:39:56 -0000

I found two solutions that worked nicely for me

1. @request.stubs(:remote_ip).returns("1.2.3.4")   #using Mocha


2.   def setup
         @controller = FooController.new
         @request    = ActionController::TestRequest.new
         @response   = ActionController::TestResponse.new

         @request.instance_eval do
           def remote_ip
             "666.13.37.911"
           end
         end
      end
--
Posted via http://www.ruby-forum.com/.