New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fb_graph-mock

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fb_graph-mock

  • 1.0.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= 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

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

== Copyright

Copyright (c) 2012 nov matake. See LICENSE for details.

FAQs

Package last updated on 13 Nov 2014

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc