Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for OPTIONS HTTP method. #39

Merged
merged 2 commits into from Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -39,6 +39,7 @@ Hock supports the 5 primary HTTP methods at this time:
* DELETE
* HEAD
* COPY
* OPTIONS

```Javascript
// Returns a hock Request object
Expand Down
17 changes: 17 additions & 0 deletions lib/hock.js
Expand Up @@ -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
*
Expand Down