ProductPromotion
Logo

Ruby

made by https://0x3d.site

GitHub - iridakos/duckrails: Development tool to mock API endpoints quickly and easily (docker image available)
Development tool to mock API endpoints quickly and easily (docker image available) - iridakos/duckrails
Visit Site

GitHub - iridakos/duckrails: Development tool to mock API endpoints quickly and easily (docker image available)

GitHub - iridakos/duckrails: Development tool to mock API endpoints quickly and easily (docker image available)

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 they 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 :duck:

Home Page

How it works

The application allows creating 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

The repository's wiki pages contain all you need to know.

You can find the old DuckRails' guides at my blog.

Example

Mocks index page

Mocks index page

Changing mocks order

Change mocks order

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 becomes available to the application and you can use the endpoint:

Request Headers

Supported response functionality

You can define static or dynamic responses for a mock.

Currently supported dynamic types are:

  • Embedded Ruby
  • JavaScript

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

JavaScript

When specifying dynamic content of JavaScript type, you can read as local variables:

  • parameters: The parameters of the request
  • headers: The request headers

The script should always return a string (for JSON use JSON.stringify(your_variable))

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.
  • Copy the sample database configuration file (config/database.yml.sample) under config/database.yml and edit it to reflect your preferred db configuration (defaults to sqlite3). If you change the database adapter, make sure you include the appropriate gem in your Gemfile (ex. for mysql gem 'mysql2')
  • 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.
  • Duckrails can be run concurrently and in parallelism, thus instead of the default rails server, you may start the puma server with something like: bundle exec puma -t 8:16 -w 3

Better setup (production environment)

  • Clone the repository.
  • Copy the sample database configuration file (config/database.yml.sample) under config/database.yml and edit it to reflect your preferred db configuration (defaults to sqlite3). If you change the database adapter, make sure you include the appropriate gem in your Gemfile (ex. for mysql gem 'mysql2')
  • 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.
  • Duckrails can be run concurrently and in parallelism, thus instead of the default rails server, you may start the puma server with something like: RAILS_ENV=production bundle exec puma -t 8:16 -w 3

Database configuration

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

Docker

A docker image is available at docker hub under iridakos/duckrails.

To obtain the image use:

docker pull iridakos/duckrails

To start the application and bind it to a port (ex. 4000) use:

docker run -p 4000:80 iridakos/duckrails:latest

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.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory