Deprecated as of 10.7.0. highlight(lang, code, ...args) has been deprecated. Deprecated as of 10.7.0. Please use highlight(code, options) instead.

Step 2 - It's a test framework, so it asserts!

Please make sure your are on step 2 in your terminal by typing:

bin/step 2

Running a test against our own specification

In this second step we are going to test a simple GET endpoint. Our API is currently serving a list of Todo items on /todos.

We start by creating a yaml file describing the specification of the endpoint. (Have a look at todo-spec/todos/getAll.yml).

Let's run webspicy:

webspicy --debug todo-spec/todos/getAll.yml

Let's assert some more

If you're doing this tutorial using the docker option you will find the todo-spec/todos/getAll.yml file in the yourbackendisbroken/ folder that you created on step 0, that is on your own file system. Alternatively you can change them directly in the container, for instance using vi.

We can improve our specification in two ways:

  1. We can change the output schema from Any to a stricter schema. Let's ensure we receive an actual array of Todo items.

    Edit the specification in todo-spec/todos/getAll.yml with your favorite editor and change the output_schema as follows:

    output_schema: |-
        id: Integer
        description: String
  2. To ensure we receive 6 Todo items, assert some properties onto the output as shown below:

      content_type: application/json
      status: 200
      - size(6)

Let's run webspicy again:

webspicy --debug todo-spec/todos/getAll.yml

Try changing the assertions so that the test fails and see what happens.