From: "David A. Black" Date: 2008-08-04T03:27:43+09:00 Subject: Re: unit testing advice Hi -- On Mon, 4 Aug 2008, James Britt wrote: > Phlip wrote: >> James Britt wrote: > >>> >>> So you don't even do model generation with Rails? >>> >>> Steven: Not at all. > >> I don't know if we are discussing the same thing. This Rails command... >> >> script/generate model MyModel >> >> ...does not create "stubs". It creates all the files that back up a Model, >> including its my_model_test.rb and fixtures/my_models.yml files. >> > > That's exactly what is being talked about. > > And the issue is that it creates a model file before the developer has > written a failing test indicating the need for a model file. > > > One might assume that the developer is going to end up in the same place > anyways, so the code might as well be automatically generated, but it's > contrary to "write the spec, have it fail, then write the code to make the > spec pass". > > I'm not arguing in favor of dogmatic testing practices, justing pointing out > that there is at least one person who actually walks the walk. > > (Besides, when a developer selects Rails as their toolkit they've already > made many code choices long before there are any tests to drive those > decisions, so the TDD/BDD purity thing is sort of a moot point.) I don't think anything in Rails militates against a test-driven approach, though -- in fact, by creating test files for you, and having the default 'rake' command be to run your tests, it creates a very hospitable environment for testing. If you don't write tests, you're always reminded of their (non)existence by the presence of the files. David -- Rails training from David A. Black and Ruby Power and Light: * Advancing With Rails August 18-21 Edison, NJ * Co-taught by D.A. Black and Erik Kastner See http://www.rubypal.com for details and updates!