# Unit test and get request with a URL

**URL:** <https://www.ruby-forum.com/t/unit-test-and-get-request-with-a-url/63551>\
**Category:** Rails\
**Created:** [June 16, 2006, 5:42am UTC](https://www.ruby-forum.com/t/unit-test-and-get-request-with-a-url/63551 "2006-06-16T05:42:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [June 16, 2006, 5:42am UTC](https://www.ruby-forum.com/t/unit-test-and-get-request-with-a-url/63551/1 "2006-06-16T05:42:26Z")

</div>

I’m tyring to write a unit test that uses a get() method to simulate a  
get request in my functional test. However, get wants an action, and I  
have a URL. I’m trying to redirect to a URL the user tried to hit  
before logging in. After they login I want to go back to the URL they  
originally tried.

I can’t find the get() method code in the help or otherwise. I grepped  
through my entire ruby directory and I’ve checked the test\_helper, but  
it’s not there. Where the heck is it defined? And why isn’t in the  
rails API?

Thanks  
Charlie

---

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [June 16, 2006, 7:01am UTC](https://www.ruby-forum.com/t/unit-test-and-get-request-with-a-url/63551/2 "2006-06-16T07:01:03Z")

</div>

Doesn’t integration testing do what you want ?

[http://jamis.jamisbuck.org/articles/2006/03/09/integration-testing-in-rails-1-1](http://jamis.jamisbuck.org/articles/2006/03/09/integration-testing-in-rails-1-1)

it’s in the api as well:

[http://rails.outertrack.com/class/ActionController%3A%3AIntegrationTest](http://rails.outertrack.com/class/ActionController%3A%3AIntegrationTest)

/r/r

On 6/16/06, Charlie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks  
> Charlie
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Rodney  
[http://www.pinupgeek.com](http://www.pinupgeek.com)  
[http://www.dutchrailers.org](http://www.dutchrailers.org)

---

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [June 16, 2006, 3:26pm UTC](https://www.ruby-forum.com/t/unit-test-and-get-request-with-a-url/63551/3 "2006-06-16T15:26:00Z")

</div>

I suppose I could start an integration test instead of my functional  
test, but I’m still curious as to where the code is? The functional  
test I’m writing doesn’t require that I go across controllers though to  
test this. I could write this test as a functional if I could do a get  
with a URL. Is there some API that I could call to break URL into a  
Hash of :action =\> “whatever”? Like using the route URL generation code  
to break it into a Hash? That way I could use the default get() method.

Thanks  
Charlie

Rodney R. wrote:

> Doesn’t integration testing do what you want ?
> 
> [http://jamis.jamisbuck.org/articles/2006/03/09/integration-testing-in-rails-1-1](http://jamis.jamisbuck.org/articles/2006/03/09/integration-testing-in-rails-1-1)
> 
> it’s in the api as well:
> 
> [http://rails.outertrack.com/class/ActionController%3A%3AIntegrationTest](http://rails.outertrack.com/class/ActionController%3A%3AIntegrationTest)
> 
> /r/r

---

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [June 16, 2006, 8:29pm UTC](https://www.ruby-forum.com/t/unit-test-and-get-request-with-a-url/63551/4 "2006-06-16T20:29:02Z")

</div>

I struggled a bit with this too. The get code seems to be actually  
contained in the process code. Check out this entry in the API:  
[http://api.rubyonrails.org/classes/ActionController/TestProcess.html#M000046](http://api.rubyonrails.org/classes/ActionController/TestProcess.html#M000046)

I _think_ the process is implicit in the get call, but like you I found  
the apparent lack lack of Api info on the functional tests a it of a  
prob.

HTH

---

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [June 17, 2006, 7:05pm UTC](https://www.ruby-forum.com/t/unit-test-and-get-request-with-a-url/63551/5 "2006-06-17T19:05:31Z")

</div>

Ok I went back and read your post. At first I thought I got it, but  
after thinking about it more it didn’t make much sense. So back to  
hunting through the rails code to find my answer. The get method’s  
aren’t in the docs because they’re generated dynamically on the fly  
using this method  
([http://api.rubyonrails.org/classes/ActionController/TestProcess.html#M000045](http://api.rubyonrails.org/classes/ActionController/TestProcess.html#M000045))  
This might have been what you were trying to tell me, but I guess I  
missed it. Thanks Chris T for giving me a more straight forward answer.

That’s how the get, post, etc methods get in your Test::Unit::TestCase.  
And you’re right they end up calling process. Very sneaky, and  
wonderfully undocumented! Errggg. I’ve wasted two days trying to  
understand this, and I don’t think it gets me any closer to my goal.

Charlie

Chris T wrote:

> I struggled a bit with this too. The get code seems to be actually  
> contained in the process code. Check out this entry in the API:  
> [http://api.rubyonrails.org/classes/ActionController/TestProcess.html#M000046](http://api.rubyonrails.org/classes/ActionController/TestProcess.html#M000046)
> 
> I _think_ the process is implicit in the get call, but like you I found  
> the apparent lack lack of Api info on the functional tests a it of a  
> prob.
> 
> HTH
