PageRenderTime 52ms CodeModel.GetById 20ms app.highlight 1ms RepoModel.GetById 19ms app.codeStats 0ms

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