mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
fix cucumber steps for csv array response
This commit is contained in:
parent
2ce1c34366
commit
21f76d76e5
3 changed files with 19 additions and 6 deletions
|
@ -16,15 +16,18 @@ Feature: Handles Multiple Formats
|
|||
|
||||
Scenario: A CSV service
|
||||
Given a remote service that returns:
|
||||
"""
|
||||
"Last Name","Name"
|
||||
"jennings","waylon"
|
||||
"cash","johnny"
|
||||
"""
|
||||
"""
|
||||
"Last Name","Name"
|
||||
"jennings","waylon"
|
||||
"cash","johnny"
|
||||
"""
|
||||
And that service is accessed at the path '/service.csv'
|
||||
And the response from the service has a Content-Type of 'application/csv'
|
||||
When I call HTTParty#get with '/service.csv'
|
||||
Then it should return a multidimensional array equaling: '[["Last Name","Name"],["jennings","waylon"],["cash","johnny"]]'
|
||||
Then it should return an Array equaling:
|
||||
| Last Name | Name |
|
||||
| jennings | waylon |
|
||||
| cash | johnny |
|
||||
|
||||
Scenario: A JSON service
|
||||
Given a remote service that returns '{ "jennings": "waylon", "cash": "johnny" }'
|
||||
|
|
|
@ -29,6 +29,11 @@ Then /it should return a Hash equaling:/ do |hash_table|
|
|||
end
|
||||
end
|
||||
|
||||
Then /it should return an Array equaling:/ do |array|
|
||||
@response_from_httparty.should be_an_instance_of(Array)
|
||||
@response_from_httparty.should eql array.raw
|
||||
end
|
||||
|
||||
Then /it should return a response with a (\d+) response code/ do |code|
|
||||
@response_from_httparty.code.should eql(code.to_i)
|
||||
end
|
||||
|
|
|
@ -3,6 +3,11 @@ Given /a remote service that returns '(.*)'/ do |response_body|
|
|||
Given "the response from the service has a body of '#{response_body}'"
|
||||
end
|
||||
|
||||
Given /^a remote service that returns:$/ do |response_body|
|
||||
@handler = BasicMongrelHandler.new
|
||||
@handler.response_body = response_body
|
||||
end
|
||||
|
||||
Given /a remote service that returns a (\d+) status code/ do |code|
|
||||
@handler = BasicMongrelHandler.new
|
||||
@handler.response_code = code
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue