-
Notifications
You must be signed in to change notification settings - Fork 109
Creating a simple static mock
Here we will see how we can create the simplest kind of mock, the static one.
Click the Create new mock button in the home page and fill in the fields of the General tab as shown in the picture:

Mind the path /my-static-mock and the request method get. Once done, the mock will be being served with get requests on the http://localhost:8080/my-static-mock (here I assume you have DuckRails started on port 8080)
Navigate to the Response body tab and set the Body type field to Static.

Fill in the following html code as Body content:
<!DOCTYPE html>
<html>
<head>
<title>Static mock title</title>
</head>
<body>
<h1>This is a static mock</h1>
<table>
<thead>
<tr>
<th>First column header</th>
<th>Second column header</th>
</tr>
</thead>
<thead>
<tr>
<td>First column</td>
<td>Second column</td>
</tr>
</thead>
</table>
</body>
</html>and set Content type to text/html.
Finally, change to the Headers tab and add a header:

Save the mock and navigate to http://localhost:8080/my-static-mock
As you can see in the picture below, the mock's body content is being displayed as html and the response contains the DuckRails-Static header that we defined.

Now let's change the Content type to text/plain and check what happens. Alter the mock Content type as shown here:

Save and request the mock again. You should be seeing the Body content being rendered as plain text!

- DuckRails - 2017 Wiki pages.
- Feel free to request for documentation that you believe is missing by opening issues with the label
wiki