# Testing webservices in Integration Tests with Jamis Buck's r

**URL:** <https://www.ruby-forum.com/t/testing-webservices-in-integration-tests-with-jamis-bucks-r/112332>\
**Category:** Rails\
**Created:** [August 17, 2007, 4:49pm UTC](https://www.ruby-forum.com/t/testing-webservices-in-integration-tests-with-jamis-bucks-r/112332 "2007-08-17T16:49:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 17, 2007, 4:49pm UTC](https://www.ruby-forum.com/t/testing-webservices-in-integration-tests-with-jamis-bucks-r/112332/1 "2007-08-17T16:49:59Z")

</div>

Hello,

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

This is the situation.

def test\_uploading\_data  
invoke :upload, data  
invoke :upload, even\_more\_data

real\_user\_session = new\_session\_as @real\_user  
real\_user\_session.press\_magic\_button\_to\_enable\_more\_uploads

invoke :upload, super\_new\_data  
end

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!  
/usr/lib/ruby/gems/1.8/gems/actionwebservice-1.2.1/lib/  
action\_web\_service/test\_invoke.rb:32:in `prepare_request' /usr/lib/ruby/gems/1.8/gems/actionwebservice-1.2.1/lib/ 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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 3, 2008, 9:35pm UTC](https://www.ruby-forum.com/t/testing-webservices-in-integration-tests-with-jamis-bucks-r/112332/2 "2008-03-03T21:35:28Z")

</div>

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  
end

…and everything went through fine. Hope that helps!

- Eric Budd

removed\_email\_address@domain.invalid wrote:

> Hello,
> 
> I’m using Jamis B.'s recipe to do integration tests on an  
> application, but I got a nil.recycle! error while doing a webservice  
> call.
> 
> This is the situation.
> 
> def test\_uploading\_data  
> invoke :upload, data  
> invoke :upload, even\_more\_data
> 
> real\_user\_session = new\_session\_as @real\_user  
> real\_user\_session.press\_magic\_button\_to\_enable\_more\_uploads
> 
> invoke :upload, super\_new\_data  
> end
> 
> 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!  
> /usr/lib/ruby/gems/1.8/gems/actionwebservice-1.2.1/lib/  
> action\_web\_service/test\_invoke.rb:32:in `prepare_request' /usr/lib/ruby/gems/1.8/gems/actionwebservice-1.2.1/lib/ 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
