How do I test a Curl based FaceBook API implementation?
You could mock Request.dispatcher
with an expected behavior, pretty much like Fakeweb would do.
There are a few examples on this file, specially https://github.com/chrisk/fakeweb/blob/master/lib/fake_web/ext/net_http.rb#L44.
When running your tests/specs, monkey-patch the run
method of your Request
class to hook into the Marston VCR library. See the existing library_hooks
subdir for examples and ideas on how to do this -- the fakeweb implementation is a good place to start.
VCR works well with live services like Facebook's because it captures interactions "as is", and VCRs can be easily re-recorded when the services change.
I'm running into problems with your library, however. You need to require the cgi
and json
libraries; it also looks like it requires a Rails environment (it's failing to find with_indifferent_access
on Hash
).