{"id":13433335,"url":"https://github.com/iridakos/duckrails","last_synced_at":"2025-04-08T00:39:00.501Z","repository":{"id":5673706,"uuid":"53192550","full_name":"iridakos/duckrails","owner":"iridakos","description":"Development tool to mock API endpoints quickly and easily (docker image available)","archived":false,"fork":false,"pushed_at":"2023-07-13T16:31:20.000Z","size":3844,"stargazers_count":1720,"open_issues_count":33,"forks_count":107,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-03-31T23:36:38.724Z","etag":null,"topics":["api","api-server","apis","developer-tools","developers","docker","mock","mocking","productivity","webdev"],"latest_commit_sha":null,"homepage":"https://github.com/iridakos/duckrails/wiki","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iridakos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-03-05T08:55:35.000Z","updated_at":"2025-03-15T16:45:47.000Z","dependencies_parsed_at":"2024-01-08T18:03:37.142Z","dependency_job_id":"5abde315-9ac1-487f-b568-146dd3c5d7bb","html_url":"https://github.com/iridakos/duckrails","commit_stats":{"total_commits":274,"total_committers":12,"mean_commits":"22.833333333333332","dds":"0.12043795620437958","last_synced_commit":"20af6e1db4218fe9ce6f405f493e8901401d88d5"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iridakos%2Fduckrails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iridakos%2Fduckrails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iridakos%2Fduckrails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iridakos%2Fduckrails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iridakos","download_url":"https://codeload.github.com/iridakos/duckrails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247755560,"owners_count":20990620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-server","apis","developer-tools","developers","docker","mock","mocking","productivity","webdev"],"created_at":"2024-07-31T02:01:24.317Z","updated_at":"2025-04-08T00:39:00.480Z","avatar_url":"https://github.com/iridakos.png","language":"Ruby","funding_links":[],"categories":["Ruby","Testing","developer-tools","Tools"],"sub_categories":["Mocking","Other tools"],"readme":"# DuckRails [![GitHub version](https://badge.fury.io/gh/iridakos%2Fduckrails.svg?a=5)](https://badge.fury.io/gh/iridakos%2Fduckrails?a=5) [![Build Status](https://travis-ci.org/iridakos/duckrails.svg?branch=master)](https://travis-ci.org/iridakos/duckrails)\n\nDuckRails is a development tool.\n\nIts main purpose is to allow developers to quickly mock API endpoints that for many possible reasons they can't reach at a specific time.\n\n\u003e If it looks like a duck, walks like a duck and quacks like a duck, then it's a duck :duck:\n\n![Home Page](https://github.com/iridakos/duckrails/blob/master/documentation/readme/resources/duckrails-home-page.png?raw=true)\n\n## How it works\n\nThe application allows creating new routes dynamically to which developers can assign static or dynamic responses:\n\n- body\n- headers\n- content type\n- status code\n\nor even cause delays, timeouts etc.\n\n### Guides\n\nThe repository's [wiki pages](https://github.com/iridakos/duckrails/wiki) contain all you need to know.\n* [What is DuckRails?](https://github.com/iridakos/duckrails/wiki/What-is-DuckRails%3F)\n* [Setting up the application](https://github.com/iridakos/duckrails/wiki/Setting-up-the-application)\n  * [natively](https://github.com/iridakos/duckrails/wiki/Setup-DuckRails-natively)\n  * [via docker](https://github.com/iridakos/duckrails/wiki/Setup-DuckRails-via-Docker)\n* [Using DuckRails](https://github.com/iridakos/duckrails/wiki/Using-DuckRails)\n  * [The mock form](https://github.com/iridakos/duckrails/wiki/Using-the-mock-form)\n  * [The mock index page](https://github.com/iridakos/duckrails/wiki/Using-the-mock-index-page)\n* [Creating mocks](https://github.com/iridakos/duckrails/wiki/Creating-mocks)\n  * [Route paths with variables](https://github.com/iridakos/duckrails/wiki/Route-paths-with-variables)\n  * [Static mock](https://github.com/iridakos/duckrails/wiki/Creating-a-simple-static-mock)\n  * [Dynamic mock with embedded Ruby](https://github.com/iridakos/duckrails/wiki/Creating-a-dynamic-mock-with-embedded-ruby)\n  * [Dynamic mock with JavaScript](https://github.com/iridakos/duckrails/wiki/Creating-a-dynamic-mock-with-Javascript)\n  * [Mock wrapping an existing API call](https://github.com/iridakos/duckrails/wiki/Creating-a-dynamic-mock-that-wraps-an-existing-API-call)\n  * [Advanced mock (WIP)](https://github.com/iridakos/duckrails/wiki/Creating-an-advanced-mock)\n\nYou can find the old DuckRails' guides [at my blog](http://iridakos.com/2016/04/01/duckrails-guide.html).\n\n### Example\n\nMocks index page\n\n![Mocks index page](https://github.com/iridakos/duckrails/blob/master/documentation/readme/resources/duckrails-mock-index-page.png?raw=true)\n\nChanging mocks order\n\n![Change mocks order](https://github.com/iridakos/duckrails/blob/master/documentation/readme/resources/duckrails-change-mock-order.png?raw=true)\n\nSetting general mock properties\n\n![General mock properties](https://github.com/iridakos/duckrails/blob/master/documentation/readme/resources/duckrails-mock-general-tab.png?raw=true)\n\nDefining the response body\n\n![Defining the response body](https://github.com/iridakos/duckrails/blob/master/documentation/readme/resources/duckrails-mock-response-body-tab.png?raw=true)\n\nSetting response headers\n\n![Setting response headers](https://github.com/iridakos/duckrails/blob/master/documentation/readme/resources/duckrails-mock-headers-tab.png?raw=true)\n\nSetting some advanced configuration (delays, dynamic headers, content type \u0026 status)\n\n![Advanced configuration](https://github.com/iridakos/duckrails/blob/master/documentation/readme/resources/duckrails-mock-advanced.png?raw=true)\n\nUpon save the route becomes available to the application and you can use the endpoint:\n\n![Request](http://i.imgur.com/NaCIqs9.png)\n![Headers](http://i.imgur.com/1jZciKH.png)\n\n## Supported response functionality\n\nYou can define static or dynamic responses for a mock.\n\nCurrently supported dynamic types are:\n\n- Embedded Ruby\n- JavaScript\n\n### Embedded Ruby\n\nWhen specifying dynamic content of embedded Ruby (more options to be added), you can read as local variables:\n\n- `@parameters`: The parameters of the request\n- `@request`: The request\n- `@response`: The response\n\n### JavaScript\n\nWhen specifying dynamic content of JavaScript type, you can read as local variables:\n\n- `parameters`: The parameters of the request\n- `headers`: The request headers\n\nThe script should always return a string (for JSON use `JSON.stringify(your_variable)`)\n\n### Route paths\n\nYou can specify routes and access their parts in the *@parameters* variable, for example:\n\n`/authors/:author_id/posts/:post_id`\n\ngive you access to the parameters with:\n\n`@parameters[:author_id]`\n\n`@parameters[:post_id]`\n\n## Quick setup (development environment)\n\n* Clone the repository.\n* 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'`)\n* Execute `bundle install` to install the required gems.\n* Execute `rake db:setup` to setup the database.\n* Execute `rails server` to start the application on the default port.\n* Duckrails can be run concurrently and in parallelism, thus instead of the default rails server, you may start the [puma](https://github.com/puma/puma) server with something like: `bundle exec puma -t 8:16 -w 3`\n\n## Better setup (production environment)\n* Clone the repository.\n* 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'`)\n* Execute `bundle install` to install the required gems.\n* Export an env variable for your [secret key base](http://stackoverflow.com/questions/23726110/missing-production-secret-key-base-in-rails): `export SECRET_KEY_BASE=\"your_secret_key_base_here\"`\n* Execute `RAILS_ENV=production rake db:setup` to setup the database.\n* Execute `RAILS_ENV=production rake assets:precompile` to generate the assets.\n* Execute `bundle exec rails s -e production` to start the application on the default port.\n* Duckrails can be run concurrently and in parallelism, thus instead of the default rails server, you may start the [puma](https://github.com/puma/puma) server with something like: `RAILS_ENV=production bundle exec puma -t 8:16 -w 3`\n\n## Database configuration\n\nThe 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.\n\n## Docker\n\nA docker image is available at docker hub under [iridakos/duckrails](https://hub.docker.com/r/iridakos/duckrails/).\n\nTo obtain the image use:\n\n`docker pull iridakos/duckrails`\n\nTo start the application and bind it to a port (ex. 4000) use:\n\n`docker run -p 4000:80 iridakos/duckrails:latest`\n\n## Contributing\n\n1. Fork it ( https://github.com/iridakos/duckrails/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## License\n\nThis application is open source under the [MIT License](https://opensource.org/licenses/MIT) terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firidakos%2Fduckrails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firidakos%2Fduckrails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firidakos%2Fduckrails/lists"}