On Mon, Nov 7, 2011 at 16:11, Gregor Panek <[email protected]> wrote:

> Am 07.11.2011 um 21:58 schrieb Dave Aronson:

>> Don't you need to specify an id there?

> How to do that? I just started to learn how write tests for the application.

I recommend you read:

  http://guides.rubyonrails.org/testing.html

(and then all the other assorted Rails Guides).  To get you started,
it contains this snippet that might be helpful:

  Example: Calling the :show action, passing an id of 12 as the params
and setting a user_id of 5 in the session:
    get(:show, {'id' => "12"}, {'user_id' => 5})

  Another example: Calling the :view action, passing an id of 12 as
the params, this time with no session, but with a flash message.
    get(:view, {'id' => '12'}, nil, {'message' => 'booya!'})

So for your purposes, I'd think that:

    get :show, :id => '1'

might do fine, assuming that there is indeed a user with ID 1 in your
test database.

> What makes me pondering is that rake routes
> is shows that the route is available

Right, but if you look at that line:

>  user GET   /users/:id(.:format)   {:action=>"show", :controller=>"users"}

you see ":id", which means you need to supply that somehow.  (The
:format part is in parens, meaning it's optional.)

> Sorry if this question is stupid but I'm still in the learning stage

No problem, we all started there too.  :-)  Kudos to you for testing
at all, many people skip that entirely!  :-(

-Dave

-- 
LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern languages.
Where: Northern Virginia, Washington DC (near Orange Line), and remote work.
See: davearonson.com (main) * codosaur.us (code) * dare2xl.com (excellence).
Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (Aronson)

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to