Skip to content

Commit

Permalink
fix rubocop and rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNe0x1 committed Oct 21, 2024
1 parent 2684bb0 commit 2d3e8a2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/dhc/interceptors/default_timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DHC::DefaultTimeout < DHC::Interceptor
TIMEOUT = 15 # seconds

def before_init
request_options = (request.options || {})
request_options = request.options || {}
request_options[:timeout] ||= timeout || TIMEOUT
request_options[:connecttimeout] ||= connecttimeout || CONNECTTIMEOUT
end
Expand Down
3 changes: 1 addition & 2 deletions lib/dhc/interceptors/throttle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ def provider
end

def track?
(options.dig(:remaining) && [options.dig(:track), response.headers].none?(&:blank?) ||
options.dig(:remaining) && [options.dig(:track), response.headers].none?(&:blank?) ||
options.dig(:track).present?
)
end

def break?
Expand Down
6 changes: 3 additions & 3 deletions spec/interceptors/logging/main_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
%r{Before DHC request <\d+> GET http://depay.fi at \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2} Params={} Headers={.*?}}
)
expect(logger).to have_received(:info).once.with(
%r{After DHC response for request <\d+> GET http://depay.fi at \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2} Time=0ms URL=http://depay.fi:80/}
%r{After DHC response for request <\d+> GET http://depay.fi at \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2} Time=\d+(\.\d+)?ms URL=http://depay.fi:80/}
)
end

Expand All @@ -27,10 +27,10 @@
it 'does log the source if provided as option' do
DHC.get('http://depay.fi', source: source)
expect(logger).to have_received(:info).once.with(
%r{Before DHC request <\d+> GET http://depay.fi at \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2} Params={} Headers={.*?} \nCalled from #{source}}
%r{Before DHC request <\d+> GET http://depay.fi at \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2} Params={} Headers={.*?} \nCalled from #{Regexp.escape(source)}}
)
expect(logger).to have_received(:info).once.with(
%r{After DHC response for request <\d+> GET http://depay.fi at \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2} Time=0ms URL=http://depay.fi:80/ \nCalled from #{source}}
%r{After DHC response for request <\d+> GET http://depay.fi at \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2} Time=\d+(\.\d+)?ms URL=http://depay.fi:80/ \nCalled from #{Regexp.escape(source)}}
)
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/response/data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
let(:body) { { some_key: { nested: value } } }

it 'makes data from response body available' do
expect(response.data.dig("some_key", "nested")).to eq value
expect(response.data.dig('some_key', 'nested')).to eq value
end

it 'can be converted to json with the as_json method' do
expect(response.data.as_json).to eq body.as_json
end

it 'returns nil when data is not available' do
expect(response.data["something"]).to be_nil
expect(response.data['something']).to be_nil
end
end

Expand All @@ -34,7 +34,7 @@
end

it 'makes item data from response body available' do
expect(response.data.dig(0, "some_key", "nested")).to eq value
expect(response.data.dig(0, 'some_key', 'nested')).to eq value
end
end
end
Expand All @@ -57,7 +57,7 @@
DHC.get('http://listings')
rescue DHC::Error => error
expect(
error.response.request.response.data.dig("meta", "errors").detect { |item| item["code"] == 2000 }['msg']
error.response.request.response.data.dig('meta', 'errors').detect { |item| item['code'] == 2000 }['msg']
).to eq 'I like to hide error messages (this is meta).'
end
end
Expand Down

0 comments on commit 2d3e8a2

Please sign in to comment.