[rspec-users] View spec'ing style
coreyhaines at gmail.com
Sun Jan 13 12:31:32 EST 2008
I don't have a lot of experience yet with the view spec'ing, but I do have
the first way I will start:
Spec a view from the outermost level and Treat extracted partials as a
hybrid of "Extract Method" and "Extract Class"
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.
On Jan 13, 2008 12:14 PM, Kevin Olbrich <lists at ruby-forum.com> wrote:
> I've been getting my head around view spec'ing lately for a fairly
> complex project that makes heavy use of partials in views and I have hit
> up against a style puzzle.
> I see two strategies for spec'ing views:
> Develop detailed specs for each partial and then make sure that the
> final view expects that the appropriate partials are included and used.
> * it's DRY
> * you get a single point of failure if an expectation is not met
> * the final specs for a view aren't very explicit and it can be
> to figure out all the things a view does without tracing back the
> Develop a set of specs for each view that explicitly expect the
> important UI elements and treat the rest of the view as a black box
> (i.e., you don't care if a particular partial was rendered so long as
> the relevant UI elements are there).
> * It's explicit and easy to tell what each view does.
> * It's not DRY.. you will get multiple points of failure if a partial
> is changed.
> * More time consuming and it's easy to miss an expectation in a view.
> So... What are people doing? The first? The second? or some
> combination of the two?
> Posted via http://www.ruby-forum.com/.
> rspec-users mailing list
> rspec-users at rubyforge.org
The Internet's Premiere source of information about Corey Haines
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users