[rspec-users] Missing template in helper specs with a render

Charlie Bowman charlesmbowman at gmail.com
Sun Jun 7 13:52:37 EDT 2009

Sent from my iPhone

On Jun 7, 2009, at 8:54 AM, Rick DeNatale <rick.denatale at gmail.com>  

> On Sun, Jun 7, 2009 at 4:24 AM, Charlie Bowman<charlesmbowman at gmail.com 
> > wrote:
>> On Jun 6, 2009, at 10:02 PM, Zach Dennis <zach.dennis at gmail.com>  
>> wrote:
>>> For example, if I need to display a piece of information for an  
>>> admin,
>>> but not a normal user then I have no problem doing the "if
>>> current_user.admin?" check in a view:
>>>  <% if current_user.admin? %>
>>>     Foo bar baz
>>>  <% end
>> def foo_message
>>  "foo bar baz" if current_user.admin?
>> end
>> That's how I handle that. If for no other reason but easier testing.
> But that refactoring is less intention revealing since it hides the
> fact than only admins will see that message.
> If I couldn't come up with a better name for foo_message which
> revealed that, I'd probably prefer leaving the if test in the view.
> Resolving the tensions between things like "dumb views" and "intention
> revealing names" is why they pay us the big bucks! <G>
Agreed. Should be def foo_message_if_admin
And yes I know im being extreme with my view on conditional logic in  
views. I've found it very helpful to think this way about my views.  
Just by refactoring old code this way I've found and fixed bugs that  
hadn't even surfaced yet.

> -- 
> Rick DeNatale
> Blog: http://talklikeaduck.denhaven2.com/
> Twitter: http://twitter.com/RickDeNatale
> WWR: http://www.workingwithrails.com/person/9021-rick-denatale
> LinkedIn: http://www.linkedin.com/in/rickdenatale
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list