I don't have a lot of experience yet with the view spec'ing, but I do have the first way I will start:<br><br>Spec a view from the outermost level and Treat extracted partials as a hybrid of "Extract Method" and "Extract Class"
<br>This means that I would spec out the top-most view, extract a partial to remove duplication or enhance readability. If I find that two views start using the same partial, then I would extract the view tests that deal with the partial and use those as tests for the partial.
<br><br>-Corey<br><br><div class="gmail_quote">On Jan 13, 2008 12:14 PM, Kevin Olbrich <<a href="mailto:lists@ruby-forum.com">lists@ruby-forum.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I've been getting my head around view spec'ing lately for a fairly<br>complex project that makes heavy use of partials in views and I have hit<br>up against a style puzzle.<br><br>I see two strategies for spec'ing views:
<br><br>First:<br> Develop detailed specs for each partial and then make sure that the<br>final view expects that the appropriate partials are included and used.<br><br> Pros:<br> * it's DRY<br> * you get a single point of failure if an expectation is not met
<br><br> Cons:<br> * the final specs for a view aren't very explicit and it can be<br>challenging<br> to figure out all the things a view does without tracing back the<br>partials.<br><br>Second:<br> Develop a set of specs for each view that explicitly expect the
<br>important UI elements and treat the rest of the view as a black box<br>(i.e., you don't care if a particular partial was rendered so long as<br>the relevant UI elements are there).<br><br> Pros:<br> * It's explicit and easy to tell what each view does.
<br><br> Cons:<br> * It's not DRY.. you will get multiple points of failure if a partial<br> is changed.<br> * More time consuming and it's easy to miss an expectation in a view.<br><br><br>So... What are people doing? The first? The second? or some
<br>combination of the two?<br><font color="#888888">--<br>Posted via <a href="http://www.ruby-forum.com/" target="_blank">http://www.ruby-forum.com/</a>.<br>_______________________________________________<br>rspec-users mailing list
<br><a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users</a><br></font></blockquote>
</div><br><br clear="all"><br>-- <br><a href="http://www.coreyhaines.com">http://www.coreyhaines.com</a><br>The Internet's Premiere source of information about Corey Haines