{"id":24505847,"url":"https://github.com/michaeltelford/mock_service","last_synced_at":"2026-05-10T15:36:49.660Z","repository":{"id":85502262,"uuid":"114422548","full_name":"michaeltelford/mock_service","owner":"michaeltelford","description":"Mock API responses using ruby, rack and docker (compose)","archived":false,"fork":false,"pushed_at":"2020-06-25T02:15:43.000Z","size":14,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T23:34:01.250Z","etag":null,"topics":["api","docker","docker-compose","mock","mock-responses","rack","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaeltelford.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-16T00:39:15.000Z","updated_at":"2019-06-10T11:10:51.000Z","dependencies_parsed_at":"2023-03-03T13:31:23.668Z","dependency_job_id":null,"html_url":"https://github.com/michaeltelford/mock_service","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeltelford%2Fmock_service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeltelford%2Fmock_service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeltelford%2Fmock_service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeltelford%2Fmock_service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaeltelford","download_url":"https://codeload.github.com/michaeltelford/mock_service/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243707300,"owners_count":20334615,"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","docker","docker-compose","mock","mock-responses","rack","ruby"],"created_at":"2025-01-21T23:32:03.751Z","updated_at":"2026-05-10T15:36:44.625Z","avatar_url":"https://github.com/michaeltelford.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mock Service\n\nMock API responses using ruby, rack and docker (compose). Helpful for development and debugging.\n\n## Prerequisites\n\n- `docker`\n- `ruby` (if running locally)\n\n## How It Works\n\nSince this app is just a plain `rack` application, the [rack interface](https://rack.github.io) is your guide to using it; In a nutshell a rack app must return an array of status, headers and body which can be something as simple as `[200, {}, ['Hello world.']]`. That's it.\n\nEdit the `app.rb` file and add a handler which will return the response you give it. Clients can then query the endpoint and receive the mock response. Any code changes are automatically reloaded so you don't need to restart the service.\n\nSee the `docker-compose.yml` file for an example of how to slot mock service into your development workflow using docker-compose.\n\n## Mocking Responses\n\nA zero dependency, lightweight [`simple_router`](https://github.com/mynyml/simple_router) is used, allowing the following:\n\n```ruby\npost '/auth/:id' do |id|\n  respond 201, body: { 'logged_in' =\u003e true, 'user_id' =\u003e id.to_i }\nend\n```\n\nThe helper method `respond(status, type: :json, headers: {}, body: [])` can be used to send responses, saving some boiler plate code. It does some helpful things like automatically setting the content type and length headers where necessary.\n\nYou can load a file (containing HTML, JSON etc.) into a string using the helper method `file(name)`, again saving some boiler plate. Files should be placed in the `fixtures` directory.\n\n### JSON\n\nThe gem [`rack-jsonparser`](https://github.com/michaeltelford/rack_jsonparser) provides the JSON parsing middleware. This roughly means that...\n\nA response body consisting of a ruby `Hash` will automatically be converted into a JSON string as long as the response `Content-Type` header is correctly set to `application/json`. The `respond` helper method will do this for you by default.\n\nAlternatively, a `String` of JSON can be provided. It's up to you to ensure the JSON is valid.\n\n## Examples\n\nSee `app.rb` for already built examples of endpoints returning different mock responses. Edit the file as you see fit.\n\n## Usage\n\nRun `bundle exec rake help` to see the available commands for running the mock server.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaeltelford%2Fmock_service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaeltelford%2Fmock_service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaeltelford%2Fmock_service/lists"}