Socket
Book a DemoInstallSign in
Socket

fakesite

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fakesite

0.2.3
bundlerRubygems
Version published
Maintainers
1
Created
Source

Fakesite

Build Status Coverage Status

An rails plugin that provides a fake framework to stub 3-party redirect page such as payment or oauth login.

Installation

Add this line to your application's Gemfile:

gem 'fakesite', group: :development

And then execute:

bundle

Route

Add fakesite route in your config/route.rb

mount Fakesite::Engine => "/fakesite" if Rails.env.development?

Usage

Create Your Fakesite

Inherit Fakesite::Base class and implement methods:

class TestFakesite < Fakesite::Base
  # specify what the parameters will return to your site
  def parameters
    {:test_key1 => :value1, :test_key2 => :value2}
  end

  # overwrite where to return, default using return_url in external_uri query string if exsit
  def return_url
    external_params["custom_url"]
  end

  # overwrite the parameters that will pass to return_url. default is params, you can do something here
  # def return_parameters
  #   params
  # end

  # implement the rule to stub external page by redirect url
  def self.match(external_uri)
    external_uri.host == "test.com"
  end

  # after register event
  # def self.after_register
  # end
end

Class Members

You can use following properties and methods in instance of Fakesite::Base class:

options

The options that you registered.

external_uri

The original uri of external third-party.

external_params

The parameters of external_uri in query string.

params

The post parameters in the fakesite page.

user

current_user instance from devise if exists.

Register Fakesite

You can register your fakesites when rails initialize.

if Rails.env.development?
  Fakesite.register :test, TestFakesite
  # You can also pass some options if needs, and using by options in your class
  # Fakesite.register :test, TestFakesite, {:your => :option}
end

You can put the registration in config/initializers/fakesite.rb

License

The gem is available as open source under the terms of the MIT License.

Contact

The project's website is located at https://github.com/emn178/fakesite
Author: emn178@gmail.com

FAQs

Package last updated on 16 Oct 2015

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.