# How to write get functional test when there is no action by

**URL:** <https://www.ruby-forum.com/t/how-to-write-get-functional-test-when-there-is-no-action-by/97128>\
**Category:** Rails\
**Created:** [July 5, 2006, 6:13am UTC](https://www.ruby-forum.com/t/how-to-write-get-functional-test-when-there-is-no-action-by/97128 "2006-07-05T06:13:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nekapoor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ea666f/32.png) [@nekapoor](https://www.ruby-forum.com/u/nekapoor)\
**Post date:** [July 5, 2006, 6:13am UTC](https://www.ruby-forum.com/t/how-to-write-get-functional-test-when-there-is-no-action-by/97128/1 "2006-07-05T06:13:46Z")

</div>

I have following line in route.rb

#event info for an event name  
map.connect ‘event/:name\_url’,:controller =\> ‘home’,:action =\>  
‘event\_info’

It causes a URL like [http://localhost:3000/event/\_jewels\_exhibition\_](http://localhost:3000/event/_jewels_exhibition_) to  
be  
sent to the home controller with action as ‘event\_info’.

I am trying to test this action. My first gut was to write something  
like

def test\_event\_info  
get :event\_info  
assert\_response :success  
end

But this doesn’t work.

Does anyone have any idea how to creat a get request whicn transaltes  
into "  
[http://localhost:3000/event/\_jewels\_exhibition\_](http://localhost:3000/event/_jewels_exhibition_) ".

I am stuck because of this and can’t proceed with my testing.

I even tried

def test\_event\_info  
get “[http://localhost:3000/event/\_jewels\_exhibition\_](http://localhost:3000/event/_jewels_exhibition_)”  
assert\_response :success  
end

But that doesn’t work either.

---

<div class="post-metadata">

**Author:** ![nekapoor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ea666f/32.png) [@nekapoor](https://www.ruby-forum.com/u/nekapoor)\
**Post date:** [July 5, 2006, 6:26am UTC](https://www.ruby-forum.com/t/how-to-write-get-functional-test-when-there-is-no-action-by/97128/2 "2006-07-05T06:26:08Z")

</div>

This works.

def test\_event\_info  
opts = {:controller =\> “event”, :action =\> “_jewels\_exhibition_”}  
assert\_generates “event/_jewels\_exhibition_”, opts  
end

But the question remains how do I send a get request so that I could  
test  
the other things like instance variables ?

---

<div class="post-metadata">

**Author:** ![nekapoor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ea666f/32.png) [@nekapoor](https://www.ruby-forum.com/u/nekapoor)\
**Post date:** [July 5, 2006, 9:09am UTC](https://www.ruby-forum.com/t/how-to-write-get-functional-test-when-there-is-no-action-by/97128/3 "2006-07-05T09:09:22Z")

</div>

It depends what you want to test. If you want to test the lines of code  
between the def and end of your event\_info method, then synthesize a url  
and  
use the get method on it, bypassing the route. If you really want to  
push  
through the routes, then read up on integration testing, as it might be  
more  
fruitful.

HereÂ¹s a great article about testing:

[http://manuals.rubyonrails.com/read/chapter/28](http://manuals.rubyonrails.com/read/chapter/28)

However, look over integration testing. It seems like the most likely  
direction for what you want:

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

HTH
