iridakos / duckrails
- воскресенье, 13 марта 2016 г. в 16:08:14
Ruby
A development tool to quickly & dynamically mock API endpoints
DuckRails is a development tool.
If it looks like a duck, walks like a duck and quacks like a duck, then it's a duck
It's main purpose is to allow developers to quickly mock API endpoints that for many possible reasons can't reach at a specific time.
The application allows to create new routes dynamically to which developers can assign static or dynamic responses:
or even cause delays, timeouts etc.
Setting general mock properties
Defining the response body
Setting response headers
Setting some advanced configuration (delays, dynamic headers, content type & status)
Upon save the route is becoming available to the application and you can use the endpoint:
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 responseYou 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]
bundle install
to install the required gems.rake db:setup
to setup the database.rails server
to start the application on the default port.bundle install
to install the required gems.export SECRET_KEY_BASE="your_secret_key_base_here"
RAILS_ENV=production rake db:setup
to setup the database.RAILS_ENV=production rake assets:precompile
to generate the assets.bundle exec rails s -e production
to start the application on the default port.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.
You can find a tutorial here.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)