Let's create a text-based imposter with multiple stubs. Binary imposters won't
see any interesting behavior difference with only startsWith
predicates:
POST /imposters HTTP/1.1
Host: localhost:<%= port %>
Accept: application/json
Content-Type: application/json
{
"port": 4548,
"protocol": "tcp",
"mode": "text",
"stubs": [
{
"responses": [{ "is": { "data": "first response" } }],
"predicates": [{ "startsWith": { "data": "first" } }]
},
{
"responses": [{ "is": { "data": "second response" } }],
"predicates": [{ "startsWith": { "data": "second" } }]
},
{
"responses": [{ "is": { "data": "third response" } }],
"predicates": [{ "startsWith": { "data": "second" } }]
}
]
}
The match is not case-sensitive:
echo 'FIRST REQUEST' | nc localhost 4548
first response
The same is true for the second stub.
echo 'Second Request' | nc localhost 4548
second response
The third stub will never run, since it matches the same requests as the
second stub. mountebank always chooses the first stub that matches based on
the order you add them to the stubs
array when creating the
imposter.
DELETE /imposters/4548 HTTP/1.1
Host: localhost:<%= port %>
Accept: application/json