Hi all - there''s a patch I need to apply from a ticket: http://dev.rubyonrails.org/ticket/8798 The ticket appears to be stalled on the lack of a test case. I figured I''d just whip one up, but because it''s an Active Resource thing, and the test case would need to do ModelName.find(:all), I''d need to either mock the network connection or set one up. In this case setting up a mock seems kind of weak, but setting up the net con seems kind of overbearing. What''s recommended here? Giles --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 8/15/07, giles bowkett <gilesb@gmail.com> wrote:> > Hi all - there''s a patch I need to apply from a ticket: > > http://dev.rubyonrails.org/ticket/8798 > > The ticket appears to be stalled on the lack of a test case. I figured > I''d just whip one up, but because it''s an Active Resource thing, and > the test case would need to do ModelName.find(:all), I''d need to > either mock the network connection or set one up. > > In this case setting up a mock seems kind of weak, but setting up the > net con seems kind of overbearing. > > What''s recommended here?The active resource unit tests use a mock request object for testing. -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Craig McClanahan
2007-Aug-16 17:48 UTC
Re: unit testing active resource - mock or connect?
On 8/15/07, Rick Olson <technoweenie@gmail.com> wrote:> > On 8/15/07, giles bowkett <gilesb@gmail.com> wrote: > > > > Hi all - there''s a patch I need to apply from a ticket: > > > > http://dev.rubyonrails.org/ticket/8798 > > > > The ticket appears to be stalled on the lack of a test case.As original submittor, the stall has been my fault :-(. I"ve been heads down on a pretty large project that happens to be using ARes (with my patch) successfully -- but thanks for taking this on.> > I figured > > I''d just whip one up, but because it''s an Active Resource thing, and > > the test case would need to do ModelName.find(:all), I''d need to > > either mock the network connection or set one up. > > > > In this case setting up a mock seems kind of weak, but setting up the > > net con seems kind of overbearing. > > > > What''s recommended here? > > The active resource unit tests use a mock request object for testing.One thing that makes me a little uncomfortable with the ARes unit tests is that the ones that consume XML do not start from raw XML input ... they start from a Ruby Hash that is converted into XML, and therefore might *not* reflect the kind of data you might really get across the wire. Maybe that is really more appropriate for higher level testing -- but the bug that 8798 reports was not caught by the current tests ... and indeed did not bite me until I actually tried to parse XML passed across the network (from a Rails app using to_xml to serialize ActiveRecord models, which is subtly different than to_xml on a Hash). Craig McClanahan> > -- > Rick Olson > http://lighthouseapp.com > http://weblog.techno-weenie.net > http://mephistoblog.com > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Koziarski
2007-Aug-20 05:12 UTC
Re: unit testing active resource - mock or connect?
> Maybe that is really more appropriate for higher level testing -- but > the bug that 8798 reports was not caught by the current tests ... and > indeed did not bite me until I actually tried to parse XML passed > across the network (from a Rails app using to_xml to serialize > ActiveRecord models, which is subtly different than to_xml on a Hash).If there are cases where the current hash-based approaches are causing problems, then we should definitely switch at least *some* of the unit tests to use proper xml. If someone whips up a patch for that I''d happily take a look. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---