Skip to content

Commit

Permalink
Rename ErrorHandler#inspect to ErrorHandler#examine in order not to b…
Browse files Browse the repository at this point in the history
…reak LSP
  • Loading branch information
kushniryb committed May 13, 2020
1 parent d0da72c commit fc3650d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/minfraud/assessments.rb
Expand Up @@ -74,7 +74,7 @@ def self.define(endpoint)
headers: raw.headers
)

::Minfraud::ErrorHandler.inspect(response)
::Minfraud::ErrorHandler.examine(response)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/minfraud/error_handler.rb
Expand Up @@ -4,7 +4,7 @@ class << self
# Returns a response if status code is 200, rises an error otherwise
# @param [Minfraud::HTTPService::Response] response
# @return [Minfraud::HTTPService::Response] if status code is 200
def inspect(response)
def examine(response)
return response if response.status == 200

raise *STATUS_CODES.fetch(response.code, [ServerError, 'Server error'])
Expand Down
6 changes: 3 additions & 3 deletions spec/assessments_spec.rb
Expand Up @@ -29,7 +29,7 @@

before(:each) do
allow_any_instance_of(described_class).to receive(:request) { request }
allow(error_handler).to receive(:inspect)
allow(error_handler).to receive(:examine)
allow(raw_response).to receive_messages(status: 200, body: {}, headers: {})
allow(request).to receive(:perform) { raw_response }
end
Expand All @@ -50,8 +50,8 @@
)
end

it 'calls error handler for response inspection' do
expect(error_handler).to receive(:inspect)
it 'calls error handler for response examination' do
expect(error_handler).to receive(:examine)
end
end
end
8 changes: 4 additions & 4 deletions spec/error_handler_spec.rb
@@ -1,26 +1,26 @@
require 'spec_helper'

describe Minfraud::ErrorHandler do
describe '.inspect' do
describe '.examine' do
let(:response) { Object.new }

it 'returns a response if status is 200' do
allow(response).to receive(:status) { 200 }
expect(described_class.inspect(response)).to eq response
expect(described_class.examine(response)).to eq response
end

it 'raises an error if status is not 200 and code is matched' do
allow(response).to receive(:status) { 400 }
allow(response).to receive(:code) { :IP_ADDRESS_INVALID }

expect { described_class.inspect(response) }.to raise_error(Minfraud::ClientError)
expect { described_class.examine(response) }.to raise_error(Minfraud::ClientError)
end

it 'raises ServerError if code is not matched' do
allow(response).to receive(:code) { :DUMMY }
allow(response).to receive(:status) { 503 }

expect { described_class.inspect(response) }.to raise_error(Minfraud::ServerError)
expect { described_class.examine(response) }.to raise_error(Minfraud::ServerError)
end
end
end

0 comments on commit fc3650d

Please sign in to comment.