/features/handles_multiple_formats.feature

http://github.com/jnunemaker/httparty · Gherkin Specification · 57 lines · 51 code · 6 blank · 0 comment · 1 complexity · 2555d99daa16c8be36b176f37afde904 MD5 · raw file

  1. Feature: Handles Multiple Formats
  2. As a developer
  3. I want to be able to consume remote services of many different formats
  4. And I want those formats to be automatically detected and handled
  5. Because web services take many forms
  6. And I don't want to have to do any extra work
  7. Scenario: An HTML service
  8. Given a remote service that returns '<h1>Some HTML</h1>'
  9. And that service is accessed at the path '/html_service.html'
  10. And the response from the service has a Content-Type of 'text/html'
  11. When I call HTTParty#get with '/html_service.html'
  12. Then it should return a String
  13. And the return value should match '<h1>Some HTML</h1>'
  14. Scenario: A CSV service
  15. Given a remote service that returns:
  16. """
  17. "Last Name","Name"
  18. "jennings","waylon"
  19. "cash","johnny"
  20. """
  21. And that service is accessed at the path '/service.csv'
  22. And the response from the service has a Content-Type of 'application/csv'
  23. When I call HTTParty#get with '/service.csv'
  24. Then it should return an Array equaling:
  25. | Last Name | Name |
  26. | jennings | waylon |
  27. | cash | johnny |
  28. Scenario: A JSON service
  29. Given a remote service that returns '{ "jennings": "waylon", "cash": "johnny" }'
  30. And that service is accessed at the path '/service.json'
  31. And the response from the service has a Content-Type of 'application/json'
  32. When I call HTTParty#get with '/service.json'
  33. Then it should return a Hash equaling:
  34. | key | value |
  35. | jennings | waylon |
  36. | cash | johnny |
  37. Scenario: An XML Service
  38. Given a remote service that returns '<singer>waylon jennings</singer>'
  39. And that service is accessed at the path '/service.xml'
  40. And the response from the service has a Content-Type of 'text/xml'
  41. When I call HTTParty#get with '/service.xml'
  42. Then it should return a Hash equaling:
  43. | key | value |
  44. | singer | waylon jennings |
  45. Scenario: A Javascript remote file
  46. Given a remote service that returns '$(function() { alert("hi"); });'
  47. And that service is accessed at the path '/service.js'
  48. And the response from the service has a Content-Type of 'application/javascript'
  49. When I call HTTParty#get with '/service.js'
  50. Then it should return a String
  51. And the return value should match '$(function() { alert("hi"); });'