restclient-test.el helps you turn restclient.el documents into
interactive test suites.
Its functionality is captured by the following animation:
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.
M-x flymake-goto-next-error and M-x flymake-goto-prev-error can be
used to quickly jump between failed tests when flymake-mode is
turned on.
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)And to turn on Flymake automatically for restclient-test-mode
buffers:
(add-hook 'restclient-test-mode-hook #'flymake-mode)The following table summarizes the key-bindings set up by
restclient-test-mode.
| Key binding | Command |
|---|---|
C-c C-b | restclient-test-buffer |
C-c C-t | restclient-test-current |
