Turn your restclient.el documents into interactive test suites
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.org
example.gif
example.http
restclient-test.el

README.org

restclient-test.el

restclient-test.el helps you turn restclient.el documents into interactive test suites.

Its functionality is captured by the following animation:

./example.gif

Usage

A restclient.el query can be turned into a test by adding a comment line starting with Expect: somewhere before the query, followed by the expected status code. Currently only status code testing is supported.

The test passes if the expected status code is a substring of the status code from running the query. So Expect: HTTP/1.1 200 OK, Expect: 200 OK, Expect: 200, and Expect: OK would all match an HTTP/1.1 200 OK response.

A full example is shown below (more examples can be found in example.http).

# Expect: 200 OK
GET http://httpbin.org/get

Running M-x restclient-test-current with point inside the query updates the buffer with the results of the test:

# Expect: 200 OK
# Response: HTTP/1.1 200 OK
# Result: Passed
GET http://httpbin.org/get

Running M-x restclient-test-buffer runs every test found in the current buffer and displays a summary of the test results in the echo area.

Use M-x restclient-test-next-error and M-x restclient-test-previous-error to quickly jump between failed tests.

restclient-test-mode

restclient-test-mode is a minor mode that sets up key-bindings for the commands provided by restclient-test.el.

To make restclient-test-mode activate automatically when restclient-mode is activated, add the following to your initialization file:

(add-hook 'restclient-mode-hook #'restclient-test-mode)

The following table summarizes the key-bindings set up by restclient-test-mode.

Key bindingCommand
C-c C-brestclient-test-buffer
C-c C-trestclient-test-current
M-g M-n, M-g nrestclient-test-next-error
M-g M-p, M-g prestclient-test-previous-error