Skip to content

Commit

Permalink
fix cucumber steps for csv array response
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgg committed Feb 8, 2014
1 parent 2ce1c34 commit 21f76d7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
15 changes: 9 additions & 6 deletions features/handles_multiple_formats.feature
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ Feature: Handles Multiple Formats


Scenario: A CSV service Scenario: A CSV service
Given a remote service that returns: Given a remote service that returns:
""" """
"Last Name","Name" "Last Name","Name"
"jennings","waylon" "jennings","waylon"
"cash","johnny" "cash","johnny"
""" """
And that service is accessed at the path '/service.csv' And that service is accessed at the path '/service.csv'
And the response from the service has a Content-Type of 'application/csv' And the response from the service has a Content-Type of 'application/csv'
When I call HTTParty#get with '/service.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 Scenario: A JSON service
Given a remote service that returns '{ "jennings": "waylon", "cash": "johnny" }' Given a remote service that returns '{ "jennings": "waylon", "cash": "johnny" }'
Expand Down
5 changes: 5 additions & 0 deletions features/steps/httparty_response_steps.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def constantize(camel_cased_word)
end end
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| Then /it should return a response with a (\d+) response code/ do |code|
@response_from_httparty.code.should eql(code.to_i) @response_from_httparty.code.should eql(code.to_i)
end end
Expand Down
5 changes: 5 additions & 0 deletions features/steps/remote_service_steps.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Given "the response from the service has a body of '#{response_body}'" Given "the response from the service has a body of '#{response_body}'"
end 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| Given /a remote service that returns a (\d+) status code/ do |code|
@handler = BasicMongrelHandler.new @handler = BasicMongrelHandler.new
@handler.response_code = code @handler.response_code = code
Expand Down

0 comments on commit 21f76d7

Please sign in to comment.