I have had similar experiences. If I submit the form and assert stuff about the next page that comes up then I end up with a big slow integration test like the kind you talk about as bad. It seems to me like this is an overly coupled design, but I don't know a way around it if I intend to use HTML forms as designed.
On the other hand, I can have a button click call something asynchronously. I can put the Ajax call in its own javascript object. Then I can stub that. Jasmine helps me do that quite nicely. I am not entirely sure what all of the implications of this are. It seems to me that even though the latter solution has more complexity in terms of javascript my tests are telling me that it has lower coupling and higher cohesion (i.e. page behavior is in javascript objects, not on the server. Some objects know how to talk to a server, but I can ignore those objects when I want to ignore the server.) On Fri, May 7, 2010 at 6:49 PM, J. B. Rainsberger <jbrainsber...@gmail.com> wrote: > 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 > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users