diff --git a/features/handles_multiple_formats.feature b/features/handles_multiple_formats.feature index 354caf2..a9be011 100644 --- a/features/handles_multiple_formats.feature +++ b/features/handles_multiple_formats.feature @@ -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" }' diff --git a/features/steps/httparty_response_steps.rb b/features/steps/httparty_response_steps.rb index 528bfc2..7d28171 100644 --- a/features/steps/httparty_response_steps.rb +++ b/features/steps/httparty_response_steps.rb @@ -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 diff --git a/features/steps/remote_service_steps.rb b/features/steps/remote_service_steps.rb index da0aee2..deb4732 100644 --- a/features/steps/remote_service_steps.rb +++ b/features/steps/remote_service_steps.rb @@ -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