/features/command_line.feature

http://github.com/jnunemaker/httparty · Gherkin Specification · 95 lines · 82 code · 13 blank · 0 comment · 1 complexity · c0053c9d54555aab4bacffb0e8e9214a MD5 · raw file

  1. @command_line
  2. Feature: Command Line
  3. As a developer
  4. I want to be able to harness the power of HTTParty from the command line
  5. Because that would make quick testing and debugging easy
  6. Scenario: Show help information
  7. When I run `httparty --help`
  8. Then the output should contain "-f, --format [FORMAT]"
  9. Scenario: Show current version
  10. When I run `httparty --version`
  11. Then the output should contain "Version:"
  12. And the output should not contain "You need to provide a URL"
  13. Scenario: Make a get request
  14. Given a remote deflate service on port '4001'
  15. And the response from the service has a body of 'GET request'
  16. And that service is accessed at the path '/fun'
  17. When I run `httparty http://0.0.0.0:4001/fun`
  18. Then the output should contain "GET request"
  19. Scenario: Make a post request
  20. Given a remote deflate service on port '4002'
  21. And the response from the service has a body of 'POST request'
  22. And that service is accessed at the path '/fun'
  23. When I run `httparty http://0.0.0.0:4002/fun --action post --data "a=1&b=2"`
  24. Then the output should contain "POST request"
  25. Scenario: Make a put request
  26. Given a remote deflate service on port '4003'
  27. And the response from the service has a body of 'PUT request'
  28. And that service is accessed at the path '/fun'
  29. When I run `httparty http://0.0.0.0:4003/fun --action put --data "a=1&b=2"`
  30. Then the output should contain "PUT request"
  31. Scenario: Make a delete request
  32. Given a remote deflate service on port '4004'
  33. And the response from the service has a body of 'DELETE request'
  34. And that service is accessed at the path '/fun'
  35. When I run `httparty http://0.0.0.0:4004/fun --action delete`
  36. Then the output should contain "DELETE request"
  37. Scenario: Set a verbose mode
  38. Given a remote deflate service on port '4005'
  39. And the response from the service has a body of 'Some request'
  40. And that service is accessed at the path '/fun'
  41. When I run `httparty http://0.0.0.0:4005/fun --verbose`
  42. Then the output should contain "content-length"
  43. Scenario: Use service with basic authentication
  44. Given a remote deflate service on port '4006'
  45. And the response from the service has a body of 'Successfull authentication'
  46. And that service is accessed at the path '/fun'
  47. And that service is protected by Basic Authentication
  48. And that service requires the username 'user' with the password 'pass'
  49. When I run `httparty http://0.0.0.0:4006/fun --user 'user:pass'`
  50. Then the output should contain "Successfull authentication"
  51. Scenario: Get response in plain format
  52. Given a remote deflate service on port '4007'
  53. And the response from the service has a body of 'Some request'
  54. And that service is accessed at the path '/fun'
  55. When I run `httparty http://0.0.0.0:4007/fun --format plain`
  56. Then the output should contain "Some request"
  57. Scenario: Get response in json format
  58. Given a remote deflate service on port '4008'
  59. Given a remote service that returns '{ "jennings": "waylon", "cash": "johnny" }'
  60. And that service is accessed at the path '/service.json'
  61. And the response from the service has a Content-Type of 'application/json'
  62. When I run `httparty http://0.0.0.0:4008/service.json --format json`
  63. Then the output should contain '"jennings": "waylon"'
  64. Scenario: Get response in xml format
  65. Given a remote deflate service on port '4009'
  66. Given a remote service that returns '<singer>waylon jennings</singer>'
  67. And that service is accessed at the path '/service.xml'
  68. And the response from the service has a Content-Type of 'text/xml'
  69. When I run `httparty http://0.0.0.0:4009/service.xml --format xml`
  70. Then the output should contain "<singer>"
  71. Scenario: Get response in csv format
  72. Given a remote deflate service on port '4010'
  73. Given a remote service that returns:
  74. """
  75. "Last Name","Name"
  76. "jennings","waylon"
  77. "cash","johnny"
  78. """
  79. And that service is accessed at the path '/service.csv'
  80. And the response from the service has a Content-Type of 'application/csv'
  81. When I run `httparty http://0.0.0.0:4010/service.csv --format csv`
  82. Then the output should contain '["Last Name", "Name"]'