Hi, How do i write unit test without writing the validations? Is it possible to write the unit test or functional test before writing the validation and controller code? manjula -- 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 -~----------~----~----~----~------~----~------~--~---
On 12 Dec 2007, at 10:36, Manjula Rajendran wrote:> > Hi, > > How do i write unit test without writing the validations? Is it > possible > to write the unit test or functional test before writing the > validation > and controller code?You can definitely write a test without having written the controller/ model code. Obviously the test should at that point fail (if not your test is broken). People sometimes call this test-first development. It does require that you think about what your model should be doing before having actually written it (which in my book is a good thing). Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, how do i write the test case for checking the length. def test_for_ssn_no contact = Contact.new contact.ssn_no = ''-123f4'' assert !contact.valid? assert_equal ''-123f456e7t'', contact.ssn_no, "Pass" end This is my test case. I want to check the length of ssn_no should be not more than 10 digits. How do i write. And the above code is the right way to write the test case? Please help me out to write a good test cases. -- 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 -~----------~----~----~----~------~----~------~--~---