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

Rick DeNatale rick.denatale at gmail.com
Fri Apr 30 08:39:20 EDT 2010

On Fri, Apr 30, 2010 at 4:26 AM, Stefan Kanev <stefan.kanev at gmail.com> wrote:
> Hey guys.
> 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?

After my initial learning of RSpec, I don't think I've written (m)any
view specs.


1. Views shouldn't have much if any logic, so not much behavior to spec
2. Views tend to change a lot as the UI of an application evolves, so
specs tend to be brittle.

If views have a lot of logic, that's a code smell. In rails such
behavior belongs in either the controller, or a helper, and that's
where I invest my spec efforts.

Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

More information about the rspec-users mailing list