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
The active resource unit tests use a mock request object for testing.
>
> 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
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.