Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/y-yagi/dummy_oscar
https://github.com/y-yagi/dummy_oscar
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/y-yagi/dummy_oscar
- Owner: y-yagi
- License: mit
- Created: 2024-03-05T07:54:51.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-04-08T22:57:53.000Z (7 months ago)
- Last Synced: 2024-09-14T06:07:10.140Z (2 months ago)
- Language: Ruby
- Size: 39.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# DummyOscar
DummyOscar is tool for creating a dummy HTTP server and client.
## Server
You can define a path that returns a dummy response by YAML file. You can use ERB inside the file.
Example:
```yml
# sample.yaml
paths:
/:
get:
response:
status_code: 200
body: "hello,world"
/users:
post:
response:
status_code: 204
get:
response:
status_code: 200
body: '<%= File.read('test/fixtures/users.json') %>'
/users/dummy.json:
get:
response:
status_code: 200
body: <%= {name: 'dummy'}.to_json %>
content_type: 'application/json'
/users/.+/books:
get:
response:
status_code: 200
body: '[{"title":"Abc"},{"title":"deF"}]'
content_type: 'application/json'
```You can now start the dummy server.
```bash
$ dummy_oscar s -C sample.yaml
``````bash
$ curl http://localhost:8282
hello,world
$ curl http://localhost:8282/users/1/books
[{"title":"Abc"},{"title":"deF"}]
```If you want to use custom methods inside the YAML, you can pass a Ruby file that will load during the parsing of the YAML file.
```bash
$ dummy_oscar s -C sample.yaml -r ./library_for_config.rb
```## Client
You can define a path and request body by YAML file. You can use ERB inside the file.
Example:
```yml
requests:
hello:
path: "/"
method: "get"
create_user:
path: "/users"
method: "post"
body: <%= {name: 'dummy'}.to_json %>
```You can send request like the following.
```bash
$ dummy_oscar c -C sample.yml -h http://localhost:5252 -c hello
```