I''m trying out the whole TDD on my newest project, and here''s my dilemma: I am creating a login system (I know, I know... re-inventing the wheel, blah blah blah; I''m doing this to teach myself things, not because I don''t think there''s something out there that can handle what I want), and so far, I''ve realized I''m going to need a User model and a User controller. I''ve created both of them, and I''m starting to write the tests that I will be developing towards passing: my question is, should I write tests for the controller, then the model; the model, then the controller; or try to do them both in tandem? I''m having problems figuring out where to start with this, as I''ve never done TDD before and I''m fairly new to the Rails game in general. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Do the model first, since the controller will depend on the model. -- Building an e-commerce site with Rails? http://www.agilewebdevelopment.com/rails-ecommerce Meet up at RailsConf: http://railsconf2007.conferencemeetup.com/ On Jan 18, 2007, at 6:20 AM, Luke Ivers wrote:> > I''m trying out the whole TDD on my newest project, and here''s my > dilemma: > > I am creating a login system (I know, I know... re-inventing the > wheel, > blah blah blah; I''m doing this to teach myself things, not because I > don''t think there''s something out there that can handle what I want), > and so far, I''ve realized I''m going to need a User model and a User > controller. I''ve created both of them, and I''m starting to write the > tests that I will be developing towards passing: my question is, > should > I write tests for the controller, then the model; the model, then the > controller; or try to do them both in tandem? I''m having problems > figuring out where to start with this, as I''ve never done TDD > before and > I''m fairly new to the Rails game in general.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I did this exact same exercise when I was learning rails and it''s a GREAT way to pick up both TDD and Rails because down the line you''ll be able to compare your results against some of the login generators out there and see where you and the others differ. It''ll also give you a thorough understanding of your login system which sadly, if generated, can be a hole in someone''s intellectual command of one of the most crucial pieces of their application. For learning TDD I suggest checking out Geoffrey Grosenbach''s peep cast on it: http://peepcode.com/products/test-first-development Oh and also if you want a headstart on the login system Chad Fowler''s Rails Recipes has some nuggets for both authentication and authorization. I haven''t viewed this particular peepcast but I''ve watched the others and they are excellent. Good luck, Tim Case tim-itakfFKLDA/2IRrHB3mpnw@public.gmane.org On 1/18/07, Benjamin Curtis <rails-4dtGyw5agdmakBO8gow8eQ@public.gmane.org> wrote:> Do the model first, since the controller will depend on the model. > > -- > Building an e-commerce site with Rails? > http://www.agilewebdevelopment.com/rails-ecommerce > > Meet up at RailsConf: > http://railsconf2007.conferencemeetup.com/ > > On Jan 18, 2007, at 6:20 AM, Luke Ivers wrote: > > > > > I''m trying out the whole TDD on my newest project, and here''s my > > dilemma: > > > > I am creating a login system (I know, I know... re-inventing the > > wheel, > > blah blah blah; I''m doing this to teach myself things, not because I > > don''t think there''s something out there that can handle what I want), > > and so far, I''ve realized I''m going to need a User model and a User > > controller. I''ve created both of them, and I''m starting to write the > > tests that I will be developing towards passing: my question is, > > should > > I write tests for the controller, then the model; the model, then the > > controller; or try to do them both in tandem? I''m having problems > > figuring out where to start with this, as I''ve never done TDD > > before and > > I''m fairly new to the Rails game in general. > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 1/18/07, Luke Ivers <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I''m trying out the whole TDD on my newest project, and here''s my > dilemma: > > I am creating a login systemBreak this feature up into tasks, each representing one user interaction. Example: - logout - login bad user name - log in bad password - log in first time For each one, write enough Railage to enable only that interaction. Each one may require tweaks to a database, model, controller, and/or view. Write test cases before as many tweaks as possible. Pass all tests after every few edits. If you can''t think of a test (look up assert_select and submit_form to test the view), then at least add a test after you write the code> (I know, I know... re-inventing the wheel,Hardly. Many erudite, educated, senior, overpaid, world-class programmers still don''t TDD, and anyone who does will easily blow them away... -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Definitely test the model first. Check out Rcov as well. It''s a great way to help make sure your tests are complete. It won''t make sure you''re testing *every* possible scenario, but it''s a great start. Luke Ivers wrote:> > I''m trying out the whole TDD on my newest project, and here''s my > dilemma: > > I am creating a login system (I know, I know... re-inventing the wheel, > blah blah blah; I''m doing this to teach myself things, not because I > don''t think there''s something out there that can handle what I want), > and so far, I''ve realized I''m going to need a User model and a User > controller. I''ve created both of them, and I''m starting to write the > tests that I will be developing towards passing: my question is, should > I write tests for the controller, then the model; the model, then the > controller; or try to do them both in tandem? I''m having problems > figuring out where to start with this, as I''ve never done TDD before and > I''m fairly new to the Rails game in general. >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---