Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

database_cleaner-remote_api

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

database_cleaner-remote_api

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

DatabaseCleaner::RemoteApi

Simply creates an HTTP API for cleaning your database to be used by client tests.

Tested against ruby-head, ruby 2.0.0, ruby 1.9.3, jruby-19mode, jruby-head, and rbx-19mode

[Build Status] (https://travis-ci.org/jtescher/database_cleaner-remote_api) [Code Climate] (https://codeclimate.com/github/jtescher/database_cleaner-remote_api) [Dependency Status] (https://gemnasium.com/jtescher/database_cleaner-remote_api) [Coverage Status] (https://coveralls.io/r/jtescher/database_cleaner-remote_api)

##Installation

Add this line to your application's Gemfile:

gem 'database_cleaner-remote_api', '~> 0.1.0'

And then execute:

$ bundle

Or install it yourself as:

$ gem install database_cleaner-remote_api

Then mount as an engine in your config/routes.rb file.

Rails.application.routes.draw do
  ...
  mount DatabaseCleaner::RemoteApi::Engine => '/database_cleaner' if Rails.env.test?
  ...
end

Usage

First install DatabaseCleaner.

To use with a client application, start rails in the test environment (or whichever environment mounted the engine).

$ rails server -e test

Then you can clean the database remotely via /mount_path/clean

Example

Given a user in the database:

User.count #=> 1

When you clean the database via any client:

$ curl http://localhost:3000/database_cleaner/clean

Then the users have been removed:

User.count #=> 0

Usage (As Client)

DatabaseCleaner::RemoteApi can also be used between rails servers by the client rails app. First install the gem (You don't have to mount the engine in routes.rb)

Then configure the server URL (if different than localhost:3000/database_cleaner) in spec/support/database_cleaner-remote_api.rb

require 'database_cleaner/remote_api'
DatabaseCleaner::RemoteApi.configure do |config|
  config.server_url = 'http://localhost:3001'  # Default: http://localhost:3000
  config.server_mount_path = '/db_cleaner'     # Default: /database_cleaner
end

Then you can wipe the remote server's database after each test has been run:

RSpec.configure do |config|
  config.after(:each) do
    DatabaseCleaner::RemoteApi.clean
  end
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

FAQs

Package last updated on 29 Aug 2013

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