-
-
Save icodeecono/1490292 to your computer and use it in GitHub Desktop.
Minisculus Challenge REST API
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
Feature: a quiz | |
Background: | |
Given the quiz is configured with the questions: | |
""" | |
[ | |
{"key": "foo", "question": "1+1", "answer": "2", "reference-url": "foo.html"}, | |
{"key": "bar", "question": "1x3", "answer": "3", "reference-url": "bar.html"} | |
] | |
""" | |
And the quiz has the ending: | |
""" | |
{ | |
"key": "mission-complete", | |
"reference-url": "mission-complete.html", | |
"code": "ABC123", | |
"email": "minisculus@minisculuschallenge.com" | |
} | |
""" | |
Scenario: starting the quiz | |
When I GET /start with request headers: | |
""" | |
Accept: application/json | |
""" | |
Then the headers should contain: | |
""" | |
Location: /foo | |
""" | |
And the status should be 303 | |
Scenario: requesting a question | |
When I GET /foo with request headers: | |
""" | |
Accept: application/json | |
""" | |
Then the body should contain JSON: | |
""" | |
{ | |
"question": "1+1", | |
"reference-url": "/foo.html" | |
} | |
""" | |
And the status should be 200 | |
Scenario: answering a question incorrectly | |
Given I have the answer data | |
""" | |
{ | |
"answer": "3" | |
} | |
""" | |
When I PUT /foo with request headers: | |
""" | |
Accept: application/json | |
Content-type: application/json | |
""" | |
Then the status should be 406 | |
Scenario: answering a question with malformed JSON | |
Given I have the answer data | |
""" | |
{ | |
answer: "3" | |
} | |
""" | |
When I PUT /foo with request headers: | |
""" | |
Accept: application/json | |
Content-type: application/json | |
""" | |
Then the status should be 406 | |
And the body should contain: | |
""" | |
Unable to parse JSON. | |
""" | |
Scenario: answering a question correctly | |
Given I have the answer data | |
""" | |
{ | |
"answer": "2" | |
} | |
""" | |
When I PUT /foo with request headers: | |
""" | |
Accept: application/json | |
""" | |
Then the headers should contain: | |
""" | |
Location: /bar | |
""" | |
And the status should be 303 | |
Scenario: requesting another question | |
When I GET /bar with request headers: | |
""" | |
Accept: application/json | |
""" | |
Then the body should contain JSON: | |
""" | |
{ | |
"question": "1x3", | |
"reference-url": "/bar.html" | |
} | |
""" | |
And the status should be 200 | |
Scenario: answering the final question | |
Given I have the answer data | |
""" | |
{ | |
"answer": "3" | |
} | |
""" | |
When I PUT /bar with request headers: | |
""" | |
Accept: application/json | |
""" | |
Then the headers should contain: | |
""" | |
Location: /finish/mission-complete | |
""" | |
And the status should be 303 | |
Scenario: requesting the ending with the correct key | |
When I GET /finish/mission-complete with request headers: | |
""" | |
Accept: application/json | |
""" | |
Then the body should contain JSON: | |
""" | |
{ | |
"code": "ABC123", | |
"email": "minisculus@minisculuschallenge.com", | |
"reference-url": "/finish/mission-complete.html" | |
} | |
""" | |
And the status should be 200 | |
Scenario: requesting the ending with the incorrect key | |
When I GET /finish/i-have-finished with request headers: | |
""" | |
Accept: application/json | |
""" | |
Then the status should be 406 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment