[rspec-users] how to test this view with Rspec

Thomas R. Koll tomk32 at gmx.de
Sat Mar 14 09:50:57 EDT 2009

Am 14.03.2009 um 14:12 schrieb Zhenning Guan:

> = flash_messages
> - @user = User.find(1)

move that to the controller or a helper. always.
and if you try to find the admin with that, add a flag on the user
so you can write current_user.admin?

 > - @forum.each do |f|
 >   .group
 >     = link_to f.name, forum_path(f)

Am I wrong or shouldn't that read:
- @forums.each do |f|

And do yourself a favour and write forum not f. Otherwise easily  
mistaken as a form.

> does anyone have some good example?

About testing. Test with a current_user (e.g.  
with an admin and without any user at all.
And of course test with @forums being empty, a special response for  
that case would be nice.

ciao, tom

Thomas R. "TomK32" Koll || http://tomk32.de || http://ananasblau.com
just a geek trying to change the world
Skype: TomK32 || Mail: tomk32 at gmx.de

More information about the rspec-users mailing list