hipchat / hipchat-rb

HipChat HTTP API Wrapper in Ruby with Capistrano hooks
https://www.hipchat.com/docs/apiv2
MIT License
336 stars 172 forks source link

Issue 197 - Undefined error message when calling ServiceError#message #198

Closed dradford closed 7 years ago

dradford commented 7 years ago

The conditional in ServiceError#message was failing with undefined method when calling .present? on Net::HTTPResponse instances:

    def message
      if @response.present?
        "#{@msg}:\nResponse: #{@response.body}"
      else
        @msg
      end
    end

Changed the check for presence to a .respond_to? and added a spec for the ErrorHandler class.

    def message
      if @response.respond_to? :body
        "#{@msg}:\nResponse: #{@response.body}"
      else
        @msg
      end
    end
coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 0aa4cdc10d0121c0510c59611b3322d241a3564d on dradford:issue/197-undefined-method-error into d0797e010cb1a26dc0590b28cad630e7e4b07c56 on hipchat:master.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 0aa4cdc10d0121c0510c59611b3322d241a3564d on dradford:issue/197-undefined-method-error into d0797e010cb1a26dc0590b28cad630e7e4b07c56 on hipchat:master.

rberrelleza commented 7 years ago

Thanks!