Skip to content

amacou/rails_sandbox_server

Repository files navigation

RailsSandboxServer

Load fixture and Rollback by http api

Installation

Add this line to your application's Gemfile:

gem 'rails_sandbox_server', github: 'amacou/rails_sandbox_server'

And then execute:

$ bundle

Usage

Setup

Add this line to config/routes.rb

  mount RailsSandboxServer::Engine => '/sandbox'

Load Fixture

$ curl -X POST http://127.0.0.1:3000/sandbox/setup -d "fixture=articles"

or

$ curl -X POST http://127.0.0.1:3000/sandbox/setup -d "fixtures[]=articles&fixtures[]=comments"

default fixture load path is test/fixtures if you'd like to change fixture path, add below to your config/environments/development.rb

Rails.application.configure do
...
# add this line
config.rails_sandbox_server.fixture_path = 'some/fixtures/path'
...
end

or send fixtures_dir

$ curl -X POST http://127.0.0.1:3000/sandbox/setup -d "fixture=articles&fixtures_dir=/Users/amacou/fixtures"

if you'd like to load fixture as another class. use mapping parameter

# ex) load Article from another_articles.yml
$ curl -X POST http://127.0.0.1:3000/sandbox/setup -d "fixture=another_articles&fixtures_dir=/Users/amacou/fixtures&mapping[another_articles]=Article"

Rollback

curl -X GET http://127.0.0.1:3000/sandbox/rollback

This project rocks and uses MIT-LICENSE.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published