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

I have following line in route.rb

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

It causes a URL like http://localhost:3000/event/jewels_exhibition to
sent to the home controller with action as ‘event_info’.

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

def test_event_info
get :event_info
assert_response :success

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 ".

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
assert_response :success

But that doesn’t work either.

This works.

def test_event_info
opts = {:controller => “event”, :action => “jewels_exhibition”}
assert_generates “event/jewels_exhibition”, opts

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

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
use the get method on it, bypassing the route. If you really want to
through the routes, then read up on integration testing, as it might be

Here¹s a great article about testing:

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


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs