Skip to content

A development tool to quickly & dynamically mock API endpoints

License

Notifications You must be signed in to change notification settings

anil-mobikasa/duckrails

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DuckRails GitHub version Build Status

DuckRails is a development tool.

Its main purpose is to allow developers to quickly mock API endpoints that for many possible reasons can't reach at a specific time.

If it looks like a duck, walks like a duck and quacks like a duck, then it's a duck

Home Page

How it works

The application allows to create new routes dynamically to which developers can assign static or dynamic responses:

  • body
  • headers
  • content type
  • status code

or even cause delays, timeouts etc.

Guides

You can find DuckRails' guides here.

Example

Setting general mock properties

General mock properties

Defining the response body

Defining the response body

Setting response headers

Setting response headers

Setting some advanced configuration (delays, dynamic headers, content type & status)

Advanced configuration

Upon save the route is becoming available to the application and you can use the endpoint:

Request Headers

Embedded ruby

When specifying dynamic content of embedded ruby (more options to be added), you can read as local variables:

  • @parameters: The parameters of the request
  • @request: The request
  • @response: The response

Route paths

You can specify routes and access their parts in the @parameters variable, for example:

/authors/:author_id/posts/:post_id

give you access to the parameters with:

@parameters[:author_id]
@parameters[:post_id]

Quick setup (development environment)

  • Clone the repository.
  • Execute bundle install to install the required gems.
  • Execute rake db:setup to setup the database.
  • Execute rails server to start the application on the default port.

Better setup (production environment)

  • Clone the repository.
  • Execute bundle install to install the required gems.
  • Export an env variable for your secret key base: export SECRET_KEY_BASE="your_secret_key_base_here"
  • Execute RAILS_ENV=production rake db:setup to setup the database.
  • Execute RAILS_ENV=production rake assets:precompile to generate the assets.
  • Execute bundle exec rails s -e production to start the application on the default port.

Database configuration

The application is by default configured to use MySQL. If you want to use another configuration, update the config/database.yml accordingly to match your setup.

Contributing

  1. Fork it ( https://github.com/iridakos/duckrails/fork )
  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 a new Pull Request

License

This application is open source under the MIT License terms.

About

A development tool to quickly & dynamically mock API endpoints

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 78.2%
  • HTML 18.5%
  • CSS 2.3%
  • JavaScript 1.0%