1 Star 0 Fork 0

阿昭 / duckrails

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

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

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

You can find DuckRails' guides here.

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.
  • 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.

The MIT License (MIT) Copyright (c) 2016 Lazarus Lazaridis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

A development tool to quickly & dynamically mock API endpoints 展开 收起
Ruby
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Ruby
1
https://gitee.com/azhao-1981/duckrails.git
git@gitee.com:azhao-1981/duckrails.git
azhao-1981
duckrails
duckrails
master

搜索帮助