I have a large number of models with attributes like backup_started_at, backup_ended_at; essentially paired dates. To ensure that start dates are always on or prior to end dates, I have written a custom validation (config/initializers/validators.rb), and I am wondering how to test it. Ideas? Is there a best practice for this sort of thing? Cheers-- Charles -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
On Thu, Nov 19, 2009 at 01:55:37PM -0800, cnjohnson wrote:> ensure that start dates are always on or prior to end dates, I have > written a custom validation (config/initializers/validators.rb), and I > am wondering how to test it. Ideas? Is there a best practice for this > sort of thing?Doesn''t your unit testing exercise the validator? I''m not an expert on rails testing, but that''s where I''d expect it to checked. -- "Oh, look: rocks!" -- Doctor Who, "Destiny of the Daleks" -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
On Nov 19, 4:07 pm, "Todd A. Jacobs" <tjacobs-sndr- b4f...-S/bPM5e9wgfNLxjTenLetw@public.gmane.org> wrote:> Doesn''t your unit testing exercise the validator? I''m not an expert on > rails testing, but that''s where I''d expect it to checked. >Yes, indeed my unit tests all pass when exercising the validator, and perhaps that is all there is to it. Still, this seems like an odd way to test the validation code, and perhaps with such a simple validation unit testing the models that have the validator is enough. Cheers-- Charles -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> cnjohnson wrote: <blockquote cite="mid:5233fded-ab16-4ed9-9958-503d430b8149-YxKHwCNrRCXatUqWdiOD/mB/v6IoIuQBVpNB7YpNyf8@public.gmane.org" type="cite"> <pre wrap="">On Nov 19, 4:07 pm, "Todd A. Jacobs" <tjacobs-sndr- <a class="moz-txt-link-abbreviated" href="mailto:b4f...-S/bPM5e9wgfNLxjTenLetw@public.gmane.org">b4f...-S/bPM5e9wgfNLxjTenLetw@public.gmane.org</a>> wrote: </pre> <blockquote type="cite"> <pre wrap="">Doesn''t your unit testing exercise the validator? I''m not an expert on rails testing, but that''s where I''d expect it to checked. </pre> </blockquote> <pre wrap=""><!---->Yes, indeed my unit tests all pass when exercising the validator, and perhaps that is all there is to it. Still, this seems like an odd way to test the validation code, and perhaps with such a simple validation unit testing the models that have the validator is enough. Cheers-- Charles </pre> </blockquote> Run tests that do not validate and ones that validate to confirm both sides.<br> </body> </html> <p></p> <p>--</p> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.<br /> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org<br /> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org<br /> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.<br />