You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
nov matake edited this page Dec 6, 2012
·
1 revision
Mocking API Calls
FbGraph is using its own Graph API mocking helper gem called “fb_graph-mock”
https://github.com/nov/fb_graph-mock
It works as HTTP level mocking like webmock/fakeweb, but optimized for mocking Facebook Graph API request & response.
For fb_graph Contributers
If you are making a new mocked JSON response file, you have 2 ways to do so.
put the JSON file in spec/mock_json in fb_graph gem itself
register the JSON file to fb_graph-mock gem and make a separate pull request to the gem
If you choose 1, I’ll move your JSON file to fb_graph-mock gem, so that all fb_graph users can share your mocked JSON for their own tests.
In fb_graph-mock gem, there are 2 ways to register a mock, with and without block.
# with blockmock_graph:get,'me','users/me_private',:access_token=>'access_token'douser=FbGraph::User.me('access_token').fetchuser.website.should == 'http://matake.jp'end
# without blockmock_graph:get,'me','users/me_private',:access_token=>'access_token'user=FbGraph::User.me('access_token').fetchuser.website.should == 'http://matake.jp'
With block, fb_graph-mock asserts the mocked request is actually called in the block.
Without block, it doesn’t do such assertion.
Latter way is for use out of fb_graph gem, so please use block if you are writing specs for fb_graph itself.