Thanks, Chris, for the confirmation.  I'll try to interpret the urge to test 
a view directly as a code smell; the point about view helper methods being 
testable is a good one.  I'll also check out that Cells package - sounds 
like it may match how I'm thinking about my application more closely.

-David

On Tuesday, April 12, 2011 2:06:16 AM UTC-7, Chris Kottom wrote:
>
> Hi David,
>
> Regarding your outlook on functional testing, you're basically correct. 
>  The goal of these is to isolate the code contained in the controller layer, 
> and if you're following skinny-controller/fat-model best practice, these 
> tests will generally be pretty basic -- essentially, handle the setup and 
> action performed, and then check the variables set, the session and flash 
> state changes, the HTTP response, and the view rendered or redirect sent.
>
> As far as your question about testing individual partials, I don't 
> personally do a ton of testing on the view level as such.  I _will_ scan my 
> views every so often to see if there's a bit of logic that would be a 
> candidate for testing and refactor those into helper methods wherever 
> possible.  But as far as I know, there's not really an easy way to test 
> individual partials outside the context of the templates that render them 
> because you'd need a controller method to prepare the state and trigger the 
> call to render them.
>
> If this is something that interests you, I saw a library called Cells (
> http://cells.rubyforge.org/) a few months back that creates something like 
> a miniature MVC stack for view fragments.  I believe it's possible to test 
> these independently, so you might want to check it out and see if there's 
> anything useful for you there.
>
>

-- 
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