[Ruby] Rails view testing questions

Tom Lianza tlianza at gmail.com
Thu Sep 21 09:59:00 PDT 2006


On 9/20/06, Eric Hodel <drbrain at segment7.net> wrote:
>
> On Sep 19, 2006, at 12:51 PM, Joe Van Dyk wrote:
>
> > Hi,
> >
> > Using the view testing functionality of ZenTest (when's that going to
> > be incorporated into Rails, btw?),
>
> Likely never.  I don't think anybody on the core team really tests.


I've also heard from some people that the approach might be less "what can
we add to rails core" and more "what can we take out of core and turn into a
plugin".  (I think Dave Thomas said that on the RoR podcast at one point).
So, I agree with Eric that it's unlikely.  I'm not sure I'm totally bought
in on making everything a plugin, but there are pros and cons to each
approach.

> you can test each view and partial individually.  Which is super.
> >
> > But, how can you test to see that a partial is actually being rendered
> > correctly by a view?  Say I accidently delete the call to the partial
> > in the view.  How could a test pick up on that?
>
> I don't know yet.  There's an idea in the comments here:
>
> http://blog.segment7.net/articles/2006/09/08/render_tree-for-rails
>
> But that one is too complicated.  I may do something simpler.


Although I haven't tried it, this might be worth checking out:
http://blog.labnotes.org/2006/07/03/assert_select-plugin-for-rails/

The word is that it's going to get folded into rails core:
http://glu.ttono.us/articles/2006/09/03/assert_select-included-in-core-assert_tag-deprecated

Although it doesn't appear to check which partial is rendered, it goes a
step further and inspects the returned html.  So, arguably that's a little
more brittle, but it appears powerful enough that you could see if the
output your partial was expected to display was in fact returned.

> Also, is there a way to do something like deny_form, deny_input, etc?
>
> See deny_links_to for ideas.  I haven't needed it, so I haven't
> written it (patches welcome).
>
> --
> Eric Hodel - drbrain at segment7.net - http://blog.segment7.net
> This implementation is HODEL-HASH-9600 compliant
>
> http://trackmap.robotcoop.com
>
>
> _______________________________________________
> Ruby at zenspider.com
> http://www.zenspider.com/seattle.rb
> http://www.zenspider.com/mailman/listinfo/ruby
>


More information about the Ruby mailing list