0.0
The project is in a healthy, maintained state
The tool for creating a dummy HTTP server and client.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 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:

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

$ dummy_oscar s -C sample.yaml
$ 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.

$ 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:

requests:
  hello:
    path: "/"
    method: "get"
  create_user:
    path: "/users"
    method: "post"
    body: <%= {name: 'dummy'}.to_json %>

You can send request like the following.

$ dummy_oscar c -C sample.yml -h http://localhost:5252 -c hello