I just typed all that and then found this:
http://github.com/freelancing-god/fakeweb/commit/50b9a17ae5d020cdbaf5237e848f91561a839858
...suggesting that it's not in the core version. Any chance of doing a
pull of that feature? Pretty please?
--
Bill Kocik
> I was going to pull that patch, but then I started working on regex
> support for registering URIs instead, which seems like a more general-
> purpose solution
Huzzah! That will be awesome.
Mike
> I'm interested, though, can you tell me about your use case for
> ignoring query params? Most of the APIs I've stubbed with FakeWeb
> either don't use many query params, or they're pretty significant when
> they do. But I know there are some weird query-param-based APIs out
> there (ahem FogBugz). So I'd like to hear more about what you're
> doing!
I'm hitting the Twitter API using John Nunemaker's twitter gem, and
depending on what I'm doing it might pass a page param, or a "since"
param, or any of a number of others, but for the most part they're not
relevant to my tests, so I'd rather not have to fake all the
possibilities, I'd rather just be able to say "this is the end point -
if there are query parameters attached, ignore them".
I think regular expressions would be an excellent solution for this.
> My issue has been with the Google geocoding service I'm using in a
> model. I'm generating instances of this model frequently in my tests
> using Factory Girl. The Google geocoding API relies heavily on
> parameters, and it would be nice not to have to register each
> different type of factory with FakeWeb. I'm not sure on the best way
> to implement this (I've only glanced over the FakeWeb Registry class
> code), but I just thought I would share my use case, which I assume is
> a fairly common one. Other than that, thanks for the great gem!
If you're using geokit for this, you don't need to use FakeWeb.
Here's what I do:
1) I have a geocode_mocker.rb file whose contents you can see at:
This provides methods for mocking out the google geocoding call with
the contents of an xml fixture file on disk.
2) I have a rake task that takes an address and generates one of those
fixture files. You can see it at:
3) In my spec_helper.rb file, I just mock out addresses that I use in
various places in my test suite like:
stub_geocode_lookup("Miami, Fl","miamifl.xml")
I imagine there are probably more elegant ways to solve this, but it
works well enough for me.
Mike