facebook graph api - VCR is not recording cassettes on successful requests, only on failed ones -
I have a simple test to bring a Facebook object. I am using curl for request.
It "Finds an object from Facebook". VCR Usasekat ('Facebook') URL = "https://graph.facebook.com/" & lt; ID & gt; Access_token = # {@ access_token} & amp; # {Query_string} "curl = curl :: is expected to be easy .pars (urls). Eql ('my object & gt;') End of the end < P> My VCR configuration is as follows: Configure VCR.C | C cassette_library_dir = 'spec / fixtures / vcr_cassettes' c.hook_into: webmock end When I run the test, it passes, and the following logs:
Start with the option: {: record = & gt ;: one time, match_requests_on => gt; [ : Method ,: Yuri] ,: allow_unused_http_interactions = & gt; true: serialize_with =>: yaml,: persist_with = & gt ;: file_syst Em} [webmask] handling requests: [https://graph.facebook.com/<ID>?access_token=<TOKEN>&fields=%5B%22id%22,% receive 22account_id% 22,% 22name [Cassette: 'Facebook'] Start HTTPInteractionLink Request With Matter [: Method: Yuri] and 0 Interactions: {} [Webmock]:% 22,% 22cbaignaign_group_status% 22,% 22objective% 22% 5D] (disabled: incorrect) [Https://graph.facebook.com/<ID>?access_token=<TOKEN>&f;fields=%5B%22id%22,222%_22_date_id% 22,% 22name% for the type of identification (recordable) 22,% 22campaign_group_status% 22,% 22objective% 22% 5D] But the cassette is not recorded and the direct is empty. I have tried : record = & gt; : All for the same result
Usually, people face this error when they use an incompatible hook for the library, but it is not. I am using webmasks and using curb.
The interesting thing is that when the request is a failure, the cassette is recorded, e.g. The token has expired. << P>
= "text">
It turns out that my code is up It was slightly more complicated than it was and was performing the callback after performing the request. Something like this:
success_handler = Proc.new {return c.body_str} curl.on_success do | Easy | Success_handler.call (easy) expires This bypasses the VCR and the file is not written. Refactor code to not use callback tasks.
Comments
Post a Comment