[rspec-users] Good practices on spec'ing views?

J. B. Rainsberger jbrainsberger at gmail.com
Fri May 7 21:49:52 EDT 2010


Stefan Kanev wrote:

> I've been doing RSpec for more than a year by now, yet I cannot help but
> feel that I've never got a single view spec right. I can see that I have
> very few view specs and that my views tend be a lot messier than
> everything else. I've read the chapter in the RSpec book about spec'ing
> views, but I still think I'm not getting it right.
>
> Assuming that I'm a view spec noob, would you guys care to share your
> experience with writing them? What works and what doesn't? What should I
> avoid at all cost? And most importantly, how does the process of writing
> view specs feel?

I write view specs, and doing so encourages me to move behavior out of 
the views and into the controller. I find it easy to write specs to 
check how I render dynamic data, but still don't have a good feel for 
writing specs that check that action buttons submit the form I expect to 
submit. I imagine writing more of the latter kind of spec will encourage 
me to avoid complex form submissions.

I treat view specs like any other specs: when I have a tough time 
writing the spec, then I rethink my design choices.
-- 
J. B. Rainsberger :: http://www.jbrains.ca ::
http://www.thecodewhisperer.com


More information about the rspec-users mailing list