Skip to content

Commit

Permalink
fixed issue with resetting client
Browse files Browse the repository at this point in the history
  • Loading branch information
Sushil Nagi committed May 15, 2018
1 parent 77fbadc commit c0d0378
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
12 changes: 11 additions & 1 deletion features/gherkin/request-options.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ Feature: Set request options
| param1 | value1 |
| param2 | value2 |
When I send the request
Then I expect last response to have status as "200"
Then I expect last response to have status as "200"

Scenario: Use generator functions in inline js template to POST method to send data to a url
Given I request GET method at "https://httpbin.org/anything" url
And I set "header1" header as "value1"
When I reset the client
And I set "header2" header as "value2"
And I GET the request to "https://httpbin.org/anything"
Then I expect last response to have status as "200"
And And I expect "${store:last-response.body.headers.Header1}" to not match "value1"
And And I expect "${store:last-response.body.headers.Header2}" to match "value2"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cucumber-steps-api",
"version": "0.1.2",
"version": "0.1.3",
"description": "Cucumber step library for API testing and support functions",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion step-definitions/client.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function bodyFromFile(filepath) {
}

defineStep(
/I (?:send|(GET|POST|PATCH|PUT|DELETE|DEL|OPTIONS|HEAD|LINK)) ?(?:a|an|the)? ?(JSON|XML|FormData|json|xml|form|form-data|multipart)* request(?: to "([^"]+)")?$/,
/I (?:send|(GET|POST|PATCH|PUT|DELETE|DEL|OPTIONS|HEAD|LINK)) ?(?:a|an|the)? ?(JSON|XML|FormData|json|xml|form|form-data|multipart)? request(?: to "([^"]+)")?$/,
function(method, type, url) {
expect(this.client).to.exist;
return this.client
Expand Down
3 changes: 1 addition & 2 deletions step-definitions/request-options.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ const { Given } = require('cucumber');
const { expect } = require('chai');
const debug = require('debug')('cucumber:steps');

Given('reset the client$', function (method, url) {
Given(/reset the client$/, function() {
this.client = this.HttpClient();
return this.client.url(url).method(method);
});
Given('I request {string} method at {expression} url', function (method, url) {
return this.client.url(url).method(method);
Expand Down

0 comments on commit c0d0378

Please sign in to comment.