How to check Curl-based FaceBook API implementation?

I wrote my own FaceBook library that uses current Curl queries, not libcurl.

Is there any way to check this? I ask about this because most of the solutions involve using something like fakeweb, which, as far as I can tell, will not work here.

Existing code can be found on my github page .

+4
source share
3 answers

You can make fun of Request.dispatcher with expected behavior pretty much similar to Fakeweb.

There are several examples in this file, especially https://github.com/chrisk/fakeweb/blob/master/lib/fake_web/ext/net_http.rb#L44 .

+1
source

One approach is to use a different host / port in test mode (e.g. localhost: 12345)

Then in your test run of a sinatra or webrick server on this port, which you configure to respond to requests that your code should do

+2
source

When running your tests / specs, the monkey-patch run method of your Request class to connect to the Marston VCR library. See the existing library_hooks subdirectory for examples and ideas on how to do this - the fakeweb implementation is a good place to start.

The VCR works well with live services such as Facebook because it captures interactions β€œas is”, and VCRs can be easily overwritten when services are changed.

I have problems with your library. You will need the cgi and json libraries; it also looks like it requires a Rails environment (it does not find with_indifferent_access on Hash ).

+1
source

Source: https://habr.com/ru/post/1386504/


All Articles