mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Cucumber suite sends unique requests
Helpful for testing ephemeral response
This commit is contained in:
parent
d160df6c3b
commit
d018df223c
7 changed files with 24 additions and 24 deletions
|
@ -5,16 +5,16 @@ Feature: Basic Authentication
|
|||
Because that is not an uncommon requirement
|
||||
|
||||
Scenario: Passing no credentials to a page requiring Basic Authentication
|
||||
Given a restricted page at '/protected.html'
|
||||
When I call HTTParty#get with '/protected.html'
|
||||
Given a restricted page at '/basic_auth.html'
|
||||
When I call HTTParty#get with '/basic_auth.html'
|
||||
Then it should return a response with a 401 response code
|
||||
|
||||
Scenario: Passing proper credentials to a page requiring Basic Authentication
|
||||
Given a remote service that returns 'Authenticated Page'
|
||||
And that service is accessed at the path '/protected.html'
|
||||
And that service is accessed at the path '/basic_auth.html'
|
||||
And that service is protected by Basic Authentication
|
||||
And that service requires the username 'jcash' with the password 'maninblack'
|
||||
When I call HTTParty#get with '/protected.html' and a basic_auth hash:
|
||||
When I call HTTParty#get with '/basic_auth.html' and a basic_auth hash:
|
||||
| username | password |
|
||||
| jcash | maninblack |
|
||||
Then the return value should match 'Authenticated Page'
|
||||
|
|
|
@ -7,20 +7,20 @@ Feature: Deals with HTTP error codes
|
|||
|
||||
Scenario: A response of '404 - Not Found'
|
||||
Given a remote service that returns a 404 status code
|
||||
And that service is accessed at the path '/service.html'
|
||||
When I call HTTParty#get with '/service.html'
|
||||
And that service is accessed at the path '/404_service.html'
|
||||
When I call HTTParty#get with '/404_service.html'
|
||||
Then it should return a response with a 404 response code
|
||||
|
||||
Scenario: A response of '500 - Internal Server Error'
|
||||
Given a remote service that returns a 500 status code
|
||||
And that service is accessed at the path '/service.html'
|
||||
When I call HTTParty#get with '/service.html'
|
||||
And that service is accessed at the path '/500_service.html'
|
||||
When I call HTTParty#get with '/500_service.html'
|
||||
Then it should return a response with a 500 response code
|
||||
|
||||
Scenario: A non-successful response where I need the body
|
||||
Given a remote service that returns a 400 status code
|
||||
And the response from the service has a body of 'Bad response'
|
||||
And that service is accessed at the path '/service.html'
|
||||
When I call HTTParty#get with '/service.html'
|
||||
And that service is accessed at the path '/400_service.html'
|
||||
When I call HTTParty#get with '/400_service.html'
|
||||
Then it should return a response with a 400 response code
|
||||
And the return value should match 'Bad response'
|
||||
|
|
|
@ -5,16 +5,16 @@ Feature: Digest Authentication
|
|||
Because that is not an uncommon requirement
|
||||
|
||||
Scenario: Passing no credentials to a page requiring Digest Authentication
|
||||
Given a restricted page at '/protected.html'
|
||||
When I call HTTParty#get with '/protected.html'
|
||||
Given a restricted page at '/digest_auth.html'
|
||||
When I call HTTParty#get with '/digest_auth.html'
|
||||
Then it should return a response with a 401 response code
|
||||
|
||||
Scenario: Passing proper credentials to a page requiring Digest Authentication
|
||||
Given a remote service that returns 'Digest Authenticated Page'
|
||||
And that service is accessed at the path '/protected.html'
|
||||
And that service is accessed at the path '/digest_auth.html'
|
||||
And that service is protected by Digest Authentication
|
||||
And that service requires the username 'jcash' with the password 'maninblack'
|
||||
When I call HTTParty#get with '/protected.html' and a digest_auth hash:
|
||||
When I call HTTParty#get with '/digest_auth.html' and a digest_auth hash:
|
||||
| username | password |
|
||||
| jcash | maninblack |
|
||||
Then the return value should match 'Digest Authenticated Page'
|
||||
|
|
|
@ -7,13 +7,13 @@ Feature: Handles Compressed Responses
|
|||
Scenario: Supports deflate encoding
|
||||
Given a remote deflate service
|
||||
And the response from the service has a body of '<h1>Some HTML</h1>'
|
||||
And that service is accessed at the path '/service.html'
|
||||
When I call HTTParty#get with '/service.html'
|
||||
And that service is accessed at the path '/deflate_service.html'
|
||||
When I call HTTParty#get with '/deflate_service.html'
|
||||
Then the return value should match '<h1>Some HTML</h1>'
|
||||
|
||||
Scenario: Supports gzip encoding
|
||||
Given a remote gzip service
|
||||
And the response from the service has a body of '<h1>Some HTML</h1>'
|
||||
And that service is accessed at the path '/service.html'
|
||||
When I call HTTParty#get with '/service.html'
|
||||
And that service is accessed at the path '/gzip_service.html'
|
||||
When I call HTTParty#get with '/gzip_service.html'
|
||||
Then the return value should match '<h1>Some HTML</h1>'
|
||||
|
|
|
@ -8,9 +8,9 @@ Feature: Handles Multiple Formats
|
|||
|
||||
Scenario: An HTML service
|
||||
Given a remote service that returns '<h1>Some HTML</h1>'
|
||||
And that service is accessed at the path '/service.html'
|
||||
And that service is accessed at the path '/html_service.html'
|
||||
And the response from the service has a Content-Type of 'text/html'
|
||||
When I call HTTParty#get with '/service.html'
|
||||
When I call HTTParty#get with '/html_service.html'
|
||||
Then it should return a String
|
||||
And the return value should match '<h1>Some HTML</h1>'
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ Feature: Supports Redirection
|
|||
|
||||
Scenario: A service that redirects once
|
||||
Given a remote service that returns 'Service Response'
|
||||
And that service is accessed at the path '/service.html'
|
||||
And the url '/redirector.html' redirects to '/service.html'
|
||||
And that service is accessed at the path '/landing_service.html'
|
||||
And the url '/redirector.html' redirects to '/landing_service.html'
|
||||
When I call HTTParty#get with '/redirector.html'
|
||||
Then the return value should match 'Service Response'
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ Feature: Supports the timeout option
|
|||
|
||||
Scenario: A long running response
|
||||
Given a remote service that returns '<h1>Some HTML</h1>'
|
||||
And that service is accessed at the path '/service.html'
|
||||
And that service is accessed at the path '/long_running_service.html'
|
||||
And that service takes 2 seconds to generate a response
|
||||
When I set my HTTParty timeout option to 1
|
||||
And I call HTTParty#get with '/service.html'
|
||||
And I call HTTParty#get with '/long_running_service.html'
|
||||
Then it should raise a Timeout::Error exception
|
||||
And I wait for the server to recover
|
||||
|
|
Loading…
Reference in a new issue