
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
= FbGraph::Mock
Facebook Graph API mocking helper, originally used in fb_graph gem.
This gem simply mock HTTP request & response using webmock gem, and returns pre-registered JSON response.
It means you can use fb_graph-mock gem even with kwala, rest-client, or any other code which access to Facebook Graph API.
== Installation
gem install fb_graph-mock
== Examples
In spec_helper.rb
require 'fb_graph/mock' include FbGraph::Mock WebMock.disable_net_connect! # Optional
In foo_spec.rb
it do mock_graph :get, 'me', 'users/me_private', :access_token => 'access_token' do user = FbGraph::User.me('access_token').fetch user.website.should == 'http://matake.jp' end end
it do mock_graph :get, 'me', 'users/me_public', :status => [401, 'Unauthorized'] do lambda do FbGraph::User.fetch :me end.should raise_error FbGraph::Unauthorized end end
=== More Examples?
You can see lots of samples in fb_graph's specs. https://github.com/nov/fb_graph
== Registered Mocks and Your Custom Mocks
To improve fb_graph and other projects using this gem, keeping mock JSONs are important.
If you find any legacy response format in this gem's mock_json directory, please report an issue or send a pull request with new JSON file.
You can find all registered responses as below.
FbGraph::Mock.registered_mocks
If it's hard to share your mock JSON (e.g. because of privacy issue), you can use your own response file as below.
file_path = File.join(Rails.root, 'spec/my_own_mock_json/users/me_private.json') mock_graph :get, 'me', file_path do # Do something. end
If a file is found at the given file path, this gem uses the file.
Otherwise, this gem search a registered mock JSON file in its own registry.
mock_graph :get, 'me', 'users/albums/arjun_public' do # => uses "mock_json/users/albums/arjun_public.json" in this gem. # Do something. end
== Note on Patches/Pull Requests
== Copyright
Copyright (c) 2012 nov matake. See LICENSE for details.
FAQs
Unknown package
We found that fb_graph-mock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.