On Nov 21, 2007, at 1:22 PM, Chris Olsen wrote: > Testing models is great and would not be able to create anything > without > it, but I am finding testing the controllers and views is a pain. > > Rest based controllers don't seem to change that much when compared to > the auto-generated code that obviously works. > > As for views I fail to see why testing it with a mock model does > anything. Nothing is ensuring that when changes are made to the model > that they will also be done to the mocks then causing the test to > break. > If anything, having the false security when all tests pass is > worse, in > that it may prevent you from double checking something crucial. > > I think tests for views makes sense when there is a condition that > must > be tested, ex. if a new member must fill in additional fields that are > made visible only when they are from a certain country. A test may > then > make sense to ensure that the fields exist. > > I am still a noob, so if anyone can enlighten me I would appreciate > it.
Personally, I find view specs to be very brittle. I avoid them like the plague. Occasionally, I'll integrate_views, but only for a regression, and in that case I'll usually use real model objects. As for controller specs - your experiencing the problems that all do with mocking/stubbing. I'm sure better tools are out there, on the way, which will tell you when a stub goes out of date (maybe you've changed the name of the method, and so on). For now, though, such things don't exist. For the most part, I think the reason people are using mocks in testing a rails projects is their speed. Speed is not some secondary factor - if your test run slow, you won't run them very often. I've already experienced this on current project, where I much more apt to run the whole suite of controller specs (which exclusively use mocks) than the whole suite of model specs (which takes around 200 seconds). Scott _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users