I enter three integers with the aid of a form into the database (I believe it is :post). In the controller, I make some calculations with the numbers and save this in the database. The method in the controller is called "create_index" How can I test the calculation ? Is that a unit or functional test ? Because I would like to test the calcualtion, if the results are correctly saved in the database. Thanks for your help ! -- 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 -~----------~----~----~----~------~----~------~--~---
M. R. wrote:> I enter three integers with the aid of a form into the database (I > believe it is :post). In the controller, I make some calculations with > the numbers and save this in the database. The method in the controller > is called "create_index" > > How can I test the calculation ? Is that a unit or functional test ? > Because I would like to test the calcualtion, if the results are > correctly saved in the database.Can anyone help me ???? -- 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 -~----------~----~----~----~------~----~------~--~---
I believe the rule is: if you''re testing a method of a model, use a unit test; if you''re testing a method of a controller, use a functional test. M. R. wrote:> I enter three integers with the aid of a form into the database (I > believe it is :post). In the controller, I make some calculations with > the numbers and save this in the database. The method in the controller > is called "create_index" > > How can I test the calculation ? Is that a unit or functional test ? > Because I would like to test the calcualtion, if the results are > correctly saved in the database. > > Thanks for your help ! > >-- Lance Ivy Web Applications Developer RBS Interactive lance.ivy-eTT0+Q0rEURLdZBKzJmsdNBPR1lH4CV8@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 10/18/06, M. R. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I enter three integers with the aid of a form into the database (I > believe it is :post). In the controller, I make some calculations with > the numbers and save this in the database. The method in the controller > is called "create_index" > > How can I test the calculation ? Is that a unit or functional test ? > Because I would like to test the calcualtion, if the results are > correctly saved in the database. >I''m guessing that the calculation should be performed by the AR model, rather than in the controller directly. If you did this then it''d be very easy to unit test the model in isolation. If you knew that the model was calculating correctly then you could use a mock object in your functional controller test to make sure that the calculate method is being called. Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---