Is it just me or does anyone else miss being able to create something quickly. Once you start writing all the tests your time is now increased by a factor of 10. I agree with the logic in testing, but am I doing something wrong?
Take the simple example of a controller test for an index action that shows all the forum posts for a user account. The controller code would be something like what is shown below, and on a bad day may take a minute to do (a really bad day) ========= before_filter :login_required before_filter :find_account def index @posts = @account.posts end ========= Now the controller tests are as following, and with the make it fail, make the update, make it pass strategy would could take about 10 minutes. ========= describe PostsController, "index" do before :each do @posts = mock("posts") @account.stub!(:posts).and_return(@posts) end it "should call the find account method" do controller.should_receive(:find... do :get end it "should assign the @account model" do do :get assigns[:account] ... end it "should call the login required" do controller.should_receive.... do :get end it "should call on the account.posts" do @account.should_recei... get :index end it "should assign posts" do do_get assigns[:posts].... end end ========= Now this is a simple example, but that is a lot of extra tests for three lines of code. I don't know if it is just me, but it takes away some of the fun in being able to see results right away. I understand that with more complex code it may be easy to make a change that could have unexpected effects elsewhere. In the above example, there is no logic that would ever get changed by accident on later updates at least not by anyone who knows what they are doing. Maybe I am way out in left field with the tests that I write, but the tests above are done using the fails, update, pass sequence. I just can't see the reasoning for writing all these tests for something so simple. I guess my thing is that I like writing tests when they will eliminate a lot of manual testing ex automated scheduling class. This would require a lot of different tests to make sure that the scheduler works as it should. I also don't have a problem with model testing seeing as there may be some logic within the model that is unique to it. I do find view testing to be a very unenjoyable, and I haven't event looked at stories yet. I am not trying to say that testing isn't good and that everyone is on the wrong track, but rather wondering if, as in the example, am testing more than I should be. Thanks -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users