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

Rick DeNatale rick.denatale at gmail.com
Sun Jun 7 11:54:13 EDT 2009

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>

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

More information about the rspec-users mailing list