Fernando Perez
2009-May-23 17:42 UTC
[rspec-users] Writing specs pointed out I need to refactor my admin area
Hi, My app now nearly has 100% coverage and when refactoring the code, potential bugs are immediately pointed out. So that''s a big win. Moreover when writing specs for my controllers and views of the admin zone, I quickly realized that I was often copying/pasting code and tests. That annoyed me. Controller LOC: 700, associated tests LOC: 1500!!! That''s stupid! So I wrote an AdminController from which my other controllers inherit from, and that enables me to drastically cut down the lines of redundant code in the controller. But then what to do with the views? I still need to make sure they get rendered correctly, so I still can cut down on the tests. One solution I see is to write an abstract set of views that controllers will be using, but for some reason I think it will blow in my fa?e at some point. Some views need to display images others don''t, some display a table others don''t, etc. What do you guys do for your admin zone to make sure it is well covered with tests and that don''t feel redundant? Do you use something like Steamlined or ActiveScaffold? Regards, -- Posted via http://www.ruby-forum.com/.
Fernando Perez
2009-May-24 17:01 UTC
[rspec-users] Writing specs pointed out I need to refactor my admin area
So I tried to implement Django''s AutoAdmin, but actually it quite quickly blew in my face. Although the views all look similar, there almost as many little differences as they are models and that''s painful to abstract. So I prefer to write my views for each model. Now I have another problem, so my models are fully covered, my controllers too, but what prevents my views from having for instance an incorrect form that would be posting incorrect parameters to my controllers? How do you test that? Cucumber + Webrat? -- Posted via http://www.ruby-forum.com/.