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.
```rust 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; ```
You can use stubr as a cli for serving Wiremock stubs on a local server.
To get a list of all available options run
bash
stubr --help
The simplest usage is for serving Wiremock stubs under a directory. Example for a project exposing contracts using Spring Cloud Contract
```bash ./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.
bash
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
NOTE: Big Sur users are recommended to install with cargo or from source
bash
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
bash
cargo install stubr
bash
git clone --depth 1 https://github.com/beltram/stubr.git && cd stubr && cargo build --release && mv target/release/stubr /usr/local/bin/
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.
```bash stubr completion zsh
stubr completion bash ```
A very simple benchmark is available here