Giter VIP home page Giter VIP logo

stubby's Introduction

Build Status

stubby

A stub http server and request body recorder.

Build

$ rebar3 compile

How to use

Configuration

In rebar.config deps, have:

{stubby, {git, "git://github.com/yowcow/stubby", {branch, "master}}}

Testing

In testing, e.g., common tests, have:

init_per_suite(Config) ->
    Url = stubby:start(),
    [{url, Url} | Config].

end_per_suite(_) ->
    ok = stubby:stop().

See src/stubby.erl for more options starting up a server.

In a testcase, make a request to stubby URL, then get the most recent request to the specified path with:

{ok, #{
  headers := Headers,
  scheme := Scheme,
  host := Host,
  port := Port,
  path := Path,
  qs := QueryString,
  body := Body
 }} = stubby:get_recent("/path/to/endopoint")

When no request is recorded yet, this call blocks until the first request is made.

Endpoints

By default, a booted stubby serves:

  • /: always responds with status code 200
  • /blackhole/[...]: always responds with status code 204

Additional cowboy endpoints can be added as a start option:

stubby:start([
   {"/new/endpoint1", new_endpoint1_handler, []},
   {"/new/endpoint2", new_endpoint2_handler, []}
  ])

See also

stubby's People

Contributors

yowcow avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.