-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(http-api): improve fixtures examples
- Loading branch information
Raphaël Benitte
authored and
Raphaël Benitte
committed
Jul 2, 2017
1 parent
b4760cc
commit f84ca4b
Showing
12 changed files
with
154 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
@http_api @fixtures | ||
Feature: Using fixtures with http API extension | ||
|
||
@yaml | ||
Scenario: Setting json body from .yaml fixture file | ||
Given I mock http call to forward request body for path /users/yaml | ||
And set request json body from yaml_00 | ||
When I POST http://fake.io/users/yaml | ||
Then I should receive a 200 HTTP status code | ||
And response should match snapshot yaml_00 | ||
|
||
@yaml | ||
Scenario: Setting form body from .yaml fixture file | ||
Given I mock http call to forward request body for path /users/yaml | ||
And set request form body from yaml_00 | ||
When I POST http://fake.io/users/yaml | ||
Then I should receive a 200 HTTP status code | ||
And response should match url encoded snapshot yaml_00 | ||
|
||
@yaml | ||
Scenario: Setting json body from .yml fixture file | ||
Given I mock http call to forward request body for path /users/yml | ||
And set request json body from yaml_01 | ||
When I POST http://fake.io/users/yml | ||
Then I should receive a 200 HTTP status code | ||
And response should match snapshot yaml_01 | ||
|
||
@yaml | ||
Scenario: Setting form body from .yml fixture file | ||
Given I mock http call to forward request body for path /users/yml | ||
And set request form body from yaml_01 | ||
When I POST http://fake.io/users/yml | ||
Then I should receive a 200 HTTP status code | ||
And response should match url encoded snapshot yaml_01 | ||
|
||
@text | ||
Scenario: Setting json body from .txt fixture file | ||
Given I mock http call to forward request body for path /users/txt | ||
And set request json body from text_00 | ||
When I POST http://fake.io/users/txt | ||
Then I should receive a 200 HTTP status code | ||
And response should match snapshot text_00 | ||
|
||
@text | ||
Scenario: Setting form body from .txt fixture file | ||
Given I mock http call to forward request body for path /users/txt | ||
And set request form body from text_00 | ||
When I POST http://fake.io/users/txt | ||
Then I should receive a 200 HTTP status code | ||
And response should match snapshot text_00 | ||
|
||
@js | ||
Scenario: Setting json body from .js fixture file | ||
Given I mock http call to forward request body for path /users/js | ||
And set request json body from module_00 | ||
When I POST http://fake.io/users/js | ||
Then I should receive a 200 HTTP status code | ||
And response should match snapshot module_00 | ||
|
||
@js | ||
Scenario: Setting form body from .js fixture file | ||
Given I mock http call to forward request body for path /users/js | ||
And set request form body from module_00 | ||
When I POST http://fake.io/users/js | ||
Then I should receive a 200 HTTP status code | ||
And response should match url encoded snapshot module_00 | ||
|
||
@json | ||
Scenario: Setting json body from .json fixture file | ||
Given I mock http call to forward request body for path /users/json | ||
And set request json body from json_00 | ||
When I POST http://fake.io/users/json | ||
Then I should receive a 200 HTTP status code | ||
And response should match snapshot json_00 | ||
|
||
@json | ||
Scenario: Setting form body from .json fixture file | ||
Given I mock http call to forward request body for path /users/json | ||
And set request form body from json_00 | ||
When I POST http://fake.io/users/json | ||
Then I should receive a 200 HTTP status code | ||
And response should match url encoded snapshot json_00 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict' | ||
|
||
const querystring = require('querystring') | ||
const { defineSupportCode } = require('cucumber') | ||
const nock = require('nock') | ||
const { expect } = require('chai') | ||
|
||
defineSupportCode(({ Given, Then }) => { | ||
Given(/^I mock http call to forward request body for path (.+)$/, function(path) { | ||
nock('http://fake.io') | ||
.post(path) | ||
.reply(200, (uri, requestBody) => requestBody) | ||
}) | ||
|
||
Then(/^response should match url encoded snapshot (.+)$/, function(snapshotId) { | ||
const httpResponse = this.httpApiClient.getResponse() | ||
expect(httpResponse).to.not.be.empty | ||
|
||
return this.fixtures.load(snapshotId).then(snapshot => { | ||
expect(httpResponse.body).to.equal(querystring.stringify(snapshot)) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters