[rspec-users] Missing template in helper specs with a render
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?
> 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>
More information about the rspec-users