diff --git a/lib/httparty/response.rb b/lib/httparty/response.rb index 3193b998..abc05aea 100644 --- a/lib/httparty/response.rb +++ b/lib/httparty/response.rb @@ -40,6 +40,11 @@ def inspect end end + # Support old multiple_choice? method from pre 2.0.0 era. + if ::RUBY_VERSION >= "2.0.0" + alias_method :multiple_choice?, :multiple_choices? + end + def respond_to?(name) return true if [:request, :response, :parsed_response, :body, :headers].include?(name) parsed_response.respond_to?(name) || response.respond_to?(name) diff --git a/spec/httparty/response_spec.rb b/spec/httparty/response_spec.rb index 616243e4..19b65f38 100644 --- a/spec/httparty/response_spec.rb +++ b/spec/httparty/response_spec.rb @@ -170,7 +170,7 @@ def response_mock(klass) :length_required? => Net::HTTPLengthRequired, :method_not_allowed? => Net::HTTPMethodNotAllowed, :moved_permanently? => Net::HTTPMovedPermanently, - :multiple_choices? => Net::HTTPMultipleChoice, + :multiple_choice? => Net::HTTPMultipleChoice, :no_content? => Net::HTTPNoContent, :non_authoritative_information? => Net::HTTPNonAuthoritativeInformation, :not_acceptable? => Net::HTTPNotAcceptable, @@ -195,7 +195,14 @@ def response_mock(klass) :unsupported_media_type? => Net::HTTPUnsupportedMediaType, :use_proxy? => Net::HTTPUseProxy, :version_not_supported? => Net::HTTPVersionNotSupported - }.each do |method, klass| + } + + # Ruby 2.0, new name for this response. + if RUBY_VERSION >= "2.0.0" + SPECIFIC_CODES[:multiple_choices?] = Net::HTTPMultipleChoices + end + + SPECIFIC_CODES.each do |method, klass| it "responds to #{method}" do net_response = response_mock(klass) response = HTTParty::Response.new(@request_object, net_response, '')