<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    Test::Mountebank - Perl client library for mountebank

SYNOPSIS
        use Test::Mountebank;

        # Create mountebank client with default port 2525
        my $mb = Test::Mountebank::Client-&gt;new(
            base_url =&gt; 'http://127.0.0.1'
        );

        # Create an imposter that answers on port 4546
        my $imposter = $mb-&gt;create_imposter( port =&gt; 4546 );

        # Adds a stub to the imposter with a predicate and a response
        # (Responds to URL /foobar.json, returns JSON content '{"foo":"bar"}')
        $imposter-&gt;stub-&gt;predicate(
            path   =&gt; "/foobar.json",
            method =&gt; "GET",
        )-&gt;response(
            status_code  =&gt; 200,
            content_type =&gt; "application/json",
            # Equivalent:
            # headers    =&gt; { Content_Type =&gt; "application/json" },
            body         =&gt; { foo =&gt; "bar" },
            # Equivalent:
            # body       =&gt; '{ "foo":"bar" }',
        );

        # Adds a stub for a non-existent resource
        $imposter-&gt;stub-&gt;predicate(
            path   =&gt; "/qux/999/json",
            method =&gt; "GET",
        )-&gt;response(
            status_code  =&gt; 404,
            content_type =&gt; "application/json",
            body         =&gt; '{ "error": "No such qux: 999" }',
        );

        # Add a stub to return HTML content read from a file
        $imposter-&gt;stub-&gt;predicate(
            path   =&gt; "/foobar.html",
            method =&gt; "GET",
        )-&gt;response(
            status_code    =&gt; 200,
            content_type   =&gt; "text/html",
            body_from_file =&gt; './foobar.html',
        );

        # Clear existing imposter on port 4546
        $mb-&gt;delete_imposters(4546); # Takes more than one port number, if desired

        # Send the new imposter to mountebank
        $mb-&gt;save_imposter($imposter);

DESCRIPTION
    The example in the synopsis builds an object structure that generates
    JSON code like the following, which can be sent to the running
    mountebank instance in a POST request.

        {
            "port": 4546,
            "protocol": "http",
            "stubs": [
                {
                    "predicates": [
                        {
                            "equals": {
                                "method": "GET",
                                "path": "/foobar.json"
                            }
                        }
                    ],
                    "responses": [
                        {
                            "is": {
                                "body": {
                                    "foo": "bar"
                                },
                                "headers": {
                                    "Content-Type": "application/json"
                                },
                                "statusCode": 200
                            }
                        }
                    ]
                },
                {
                    "predicates": [
                        {
                            "equals": {
                                "method": "GET",
                                "path": "/qux/999/json"
                            }
                        }
                    ],
                    "responses": [
                        {
                            "is": {
                                "body": "{ \"error\": \"No such qux: 999\" }",
                                "headers": {
                                    "Content-Type": "application/json"
                                },
                                "statusCode": 404
                            }
                        }
                    ]
                },
                {
                    "predicates": [
                        {
                            "equals": {
                                "method": "GET",
                                "path": "/foobar.html"
                            }
                        }
                    ],
                    "responses": [
                        {
                            "is": {
                                "body": "&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;foobar&lt;/title&gt;\n  &lt;/head&gt;\n  &lt;body&gt;\n    foobar\n  &lt;/body&gt;\n&lt;/html&gt;\n\n",
                                "headers": {
                                    "Content-Type": "text/html"
                                },
                                "statusCode": 200
                            }
                        }
                    ]
                }
            ]
        }

    Compare the mountebank documentation at
    http://www.mbtest.org/docs/api/stubs and
    http://www.mbtest.org/docs/api/predicates. Currently at least,
    Test::Mountebank implements only the features of mountebank stubs that
    are most useful for simulating a REST API. There is only one type of
    predicate (`equals') and only one type of response (`is').

AUTHOR
    Dagfinn ReiersÃ¸l dagfinn@reiersol.com

COPYRIGHT
    Copyright (C) 2016, Dagfinn ReiersÃ¸l.

</pre></body></html>