Testing webservices in Integration Tests with Jamis Buck's recipe?


I'm using Jamis Buck's recipe to do integration tests on an
application, but I got a nil.recycle! error while doing a webservice

This is the situation.

def test_uploading_data
   invoke :upload, data
   invoke :upload, even_more_data

   real_user_session = new_session_as @real_user

   invoke :upload, super_new_data

Test test results in a nil.recycle! error message on the last invoke:

NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.recycle!
action_web_service/test_invoke.rb:32:in `prepare_request'
action_web_service/test_invoke.rb:9:in `invoke'

It seems that the default @request in the setup is corrupted by our
open_session implementation?
Can somebody help me on this?

Best regards,
Jeroen Knoops

Hi Jeroen,

  I was having exactly this error in my functional tests. I added the
following method to my test class:

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

...and everything went through fine. Hope that helps!

- Eric Budd