and a response
# (Responds to URL /foobar.json, returns JSON content '{"foo":"bar"}')
$imposter->stub->predicate(
path => "/foobar.json",
method => "GET",
)->response(
atus_code => 200,
content_type => "application/json",
# Equivalent:
# headers => { Content_Type => "application/json" },
body => { foo => "bar" },
#
->predicate(
path => "/qux/999/json",
method => "GET",
)->response(
status_code => 404,
content_type => "application/json",
body => '{ "error": "
ountebank::Types qw( HTTPHeaders );
use MooseX::Types::HTTPMethod qw(HTTPMethod11);
use JSON::Tiny qw(encode_json);
has method => ( is => 'ro', isa => HTTPMethod11 );
has path => ( is =>
Moose;
our $VERSION = '0.001';
use Method::Signatures;
use Test::Mountebank::Stub;
use JSON::Tiny qw(encode_json);
use Carp;
has protocol => ( is => 'rw', isa => 'Str', default => 'http' );
has port
[ $self->map_stubs( sub { $_->as_hashref } ) ],
protocol => $self->protocol,
port => $self->port,
};
}
method as_json() {
return encode_json( $self->as_hashref() );
}
1;
tures;
use Test::Mountebank::Predicate::Equals;
use Test::Mountebank::Response::Is;
use JSON::Tiny qw(encode_json);
use Carp;
has predicates => (
traits => ['Array'],
is => 'ro',
is
map_responses( sub { $_->as_hashref } ) ],
predicates => [ $self->map_predicates( sub { $_->as_hashref } ) ],
};
}
method as_json() {
return encode_json( $self->as_hashref() );
}
1;
N = '0.001';
use Method::Signatures;
use Test::Mountebank::Types qw( HTTPHeaders );
use JSON::Tiny qw(encode_json);
use File::Slurper qw/read_text/;
use Carp;
use MIME::Types;
has status_code => (
Client;
use Moose;
our $VERSION = '0.001';
use Method::Signatures;
use HTTP::Tiny;
use JSON::Tiny qw(encode_json);
use Test::Mountebank::Imposter;
has ua => (
is => 'ro',
default => sub
) {
$self->ua->post(
$self->mb_url . "/imposters",
{
headers => { "Content-Type" => "application/json" },
content => $imp->as_json,
},
);
}
1;