stubr 0.1.1

Wiremock implemented in Rust
Documentation

stubr

Build status Crates.io Docs.rs Packaging status

Adaptation of wiremock-rs supporting existing Wiremock json stubs as input.
Aims at reaching feature parity with Wiremock and be a drop-in replacement of the latter.

use it

as a crate

use stubr::Stubr;

let srv = Stubr::start("tests/stubs").await;
// or just mount a single file
let srv = Stubr::start("tests/stubs/ping.json").await;

// use '.uri()' method to get server address
surf::get( & srv.uri()).await;

as a cli

You can use stubr as a cli for serving Wiremock stubs on a local server.
To get a list of all available options run

stubr --help

The simplest usage is for serving Wiremock stubs under a directory. Example for a project exposing contracts using Spring Cloud Contract

./gradlew generateClientStubs
stubr build/stubs/META-INF/com.ecorp/my-app/SNAPSHOT/mappings
 > - mounted stub "./build/stubs/META-INF/com.ecorp/my-app/SNAPSHOT/mappings/find-all.json"
 > - mounted stub "./build/stubs/META-INF/com.ecorp/my-app/SNAPSHOT/mappings/find-by-id.json"
 > Started stubr server on http://127.0.0.1:49604

You can also specify the directory as wiremock does with the --root-dir arg.
You can enforce server port with --port or -p arg. By default, stubr starts on a random port.

install it

with precompiled binaries (linux & osx)

linux:
curl -L https://github.com/beltram/stubr/releases/download/0.1.1/stubr-linux -o /usr/local/bin/stubr && chmod +x /usr/local/bin/stubr
macos (Catalina):

NOTE: Big Sur users are recommended to install with cargo or from source

curl -L https://github.com/beltram/stubr/releases/download/0.1.1/stubr-macos -o /usr/local/bin/stubr && chmod +x /usr/local/bin/stubr

with cargo

cargo install stubr

from source (linux & osx)

git clone --depth 1 https://github.com/beltram/stubr.git && cd stubr && cargo build --release && mv target/release/stubr /usr/local/bin/

then generate completion

Completion files generation is currently supported for bash and zsh. Stubr cli provides a completion command to generate and install them in a standard location.

stubr completion zsh
# or
stubr completion bash

benchmark

A very simple benchmark is available here