From aba986f1594f188fbfc81fcf75f8a5be189c0730 Mon Sep 17 00:00:00 2001 From: Alexandru Chirila Date: Mon, 10 Dec 2018 13:28:05 +0200 Subject: [PATCH 1/2] Add support for the OPTIONS HTTP method. --- lib/hock.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/hock.js b/lib/hock.js index 378d62d..028b300 100644 --- a/lib/hock.js +++ b/lib/hock.js @@ -242,6 +242,23 @@ Hock.prototype.copy = function (url, body, headers) { }); }; +/** + * Hock.options + * + * @description enqueue a OPTIONS request into the assertion queue + * + * @param {String} url the route of the request to match + * @param {object} [headers] optionally match the request headers + * @returns {Request} + */ +Hock.prototype.options = function (url, headers) { + return new Request(this, { + method: 'OPTIONS', + url: url, + headers: headers || {} + }); +}; + /** * Hock.filteringRequestBody * From 45a69ebcd3fabe179dad751c36aa64214731fc57 Mon Sep 17 00:00:00 2001 From: Alexandru Chirila Date: Mon, 10 Dec 2018 13:28:54 +0200 Subject: [PATCH 2/2] Add OPTIONS to docs. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 06be017..8a1765a 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Hock supports the 5 primary HTTP methods at this time: * DELETE * HEAD * COPY +* OPTIONS ```Javascript // Returns a hock Request object