From 3380b34903ff98d51e789f46456a824df6e9c62a Mon Sep 17 00:00:00 2001 From: Santiago Traversa Date: Tue, 20 Apr 2021 23:12:57 -0300 Subject: [PATCH 01/13] [RSpec/VerifiedDoubles] Fixed --- .rubocop_todo.yml | 16 +++++----------- spec/dnsimple/client_spec.rb | 10 +++++----- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b2c979ab..8dfe6410 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-04-05 15:23:33 UTC using RuboCop version 1.12.1. +# on 2021-04-21 02:09:47 UTC using RuboCop version 1.12.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -14,7 +14,7 @@ RSpec/ContextWording: - 'spec/dnsimple/client/domains_collaborators_spec.rb' - 'spec/dnsimple/options/list_options_spec.rb' -# Offense count: 70 +# Offense count: 71 # Configuration parameters: Max. RSpec/ExampleLength: Enabled: false @@ -32,9 +32,9 @@ RSpec/MessageSpies: # Offense count: 117 RSpec/MultipleExpectations: - Max: 16 + Max: 15 -# Offense count: 374 +# Offense count: 375 # Configuration parameters: IgnoreSharedExamples. RSpec/NamedSubject: Enabled: false @@ -60,13 +60,7 @@ RSpec/SubjectStub: - 'spec/dnsimple/client/zones_spec.rb' - 'spec/dnsimple/client_spec.rb' -# Offense count: 5 -# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. -RSpec/VerifiedDoubles: - Exclude: - - 'spec/dnsimple/client_spec.rb' - -# Offense count: 39 +# Offense count: 37 # Configuration parameters: AllowedConstants. Style/Documentation: Enabled: false diff --git a/spec/dnsimple/client_spec.rb b/spec/dnsimple/client_spec.rb index 12a06db7..13666a7f 100644 --- a/spec/dnsimple/client_spec.rb +++ b/spec/dnsimple/client_spec.rb @@ -133,7 +133,7 @@ basic_auth: { username: "user", password: "pass" }, headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT } ) - .and_return(double('response', code: 200)) + .and_return(instance_double('response', code: 200)) subject.request(:get, 'foo') end @@ -148,7 +148,7 @@ basic_auth: { username: "user", password: "pass" }, headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT, "Custom" => "Header" } ) - .and_return(double('response', code: 200)) + .and_return(instance_double('response', code: 200)) subject.request(:put, 'foo', { something: "else" }, { query: { foo: "bar" }, headers: { "Custom" => "Header" } }) end @@ -162,7 +162,7 @@ basic_auth: { username: "user", password: "pass" }, headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded', 'User-Agent' => Dnsimple::Default::USER_AGENT } ) - .and_return(double('response', code: 200)) + .and_return(instance_double('response', code: 200)) subject.request(:post, 'foo', { something: "else" }, { headers: { "Content-Type" => "application/x-www-form-urlencoded" } }) end @@ -176,7 +176,7 @@ http_proxyport: "4321", headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT } ) - .and_return(double('response', code: 200)) + .and_return(instance_double('response', code: 200)) subject = described_class.new(proxy: "example-proxy.com:4321") subject.request(:get, "test", nil, {}) @@ -189,7 +189,7 @@ format: :json, headers: hash_including("User-Agent" => "customAgent #{Dnsimple::Default::USER_AGENT}") ) - .and_return(double("response", code: 200)) + .and_return(instance_double("response", code: 200)) subject = described_class.new(user_agent: "customAgent") subject.request(:get, "test", nil) From 64213a38574efa930258c98659e4654458fc4cd6 Mon Sep 17 00:00:00 2001 From: Santiago Traversa Date: Tue, 20 Apr 2021 23:15:23 -0300 Subject: [PATCH 02/13] [RSpec/StubbedMock] Fixed Prefer allow over expect when configuring a response --- .rubocop_todo.yml | 7 +------ spec/dnsimple/client_spec.rb | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8dfe6410..16f9a6ab 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-04-21 02:09:47 UTC using RuboCop version 1.12.1. +# on 2021-04-21 02:13:15 UTC using RuboCop version 1.12.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -39,11 +39,6 @@ RSpec/MultipleExpectations: RSpec/NamedSubject: Enabled: false -# Offense count: 10 -RSpec/StubbedMock: - Exclude: - - 'spec/dnsimple/client_spec.rb' - # Offense count: 16 RSpec/SubjectStub: Exclude: diff --git a/spec/dnsimple/client_spec.rb b/spec/dnsimple/client_spec.rb index 13666a7f..52d3c459 100644 --- a/spec/dnsimple/client_spec.rb +++ b/spec/dnsimple/client_spec.rb @@ -49,35 +49,35 @@ describe "#get" do it "delegates to #request" do - expect(subject).to receive(:execute).with(:get, "path", nil, foo: "bar").and_return(:returned) + allow(subject).to receive(:execute).with(:get, "path", nil, foo: "bar").and_return(:returned) expect(subject.get("path", foo: "bar")).to eq(:returned) end end describe "#post" do it "delegates to #request" do - expect(subject).to receive(:execute).with(:post, "path", { foo: "bar" }, {}).and_return(:returned) + allow(subject).to receive(:execute).with(:post, "path", { foo: "bar" }, {}).and_return(:returned) expect(subject.post("path", foo: "bar")).to eq(:returned) end end describe "#put" do it "delegates to #request" do - expect(subject).to receive(:execute).with(:put, "path", { foo: "bar" }, {}).and_return(:returned) + allow(subject).to receive(:execute).with(:put, "path", { foo: "bar" }, {}).and_return(:returned) expect(subject.put("path", foo: "bar")).to eq(:returned) end end describe "#patch" do it "delegates to #request" do - expect(subject).to receive(:execute).with(:patch, "path", { foo: "bar" }, {}).and_return(:returned) + allow(subject).to receive(:execute).with(:patch, "path", { foo: "bar" }, {}).and_return(:returned) expect(subject.patch("path", foo: "bar")).to eq(:returned) end end describe "#delete" do it "delegates to #request" do - expect(subject).to receive(:execute).with(:delete, "path", { foo: "bar" }, {}).and_return(:returned) + allow(subject).to receive(:execute).with(:delete, "path", { foo: "bar" }, {}).and_return(:returned) expect(subject.delete("path", foo: "bar")).to eq(:returned) end end @@ -126,7 +126,7 @@ it "delegates to HTTParty" do stub_request(:get, %r{/foo}) - expect(HTTParty).to receive(:get) + allow(HTTParty).to receive(:get) .with( "#{subject.base_url}foo", format: :json, @@ -139,7 +139,7 @@ end it "properly extracts processes options and encodes data" do - expect(HTTParty).to receive(:put) + allow(HTTParty).to receive(:put) .with( "#{subject.base_url}foo", format: :json, @@ -154,7 +154,7 @@ end it "handles non application/json content types" do - expect(HTTParty).to receive(:post) + allow(HTTParty).to receive(:post) .with( "#{subject.base_url}foo", format: :json, @@ -168,7 +168,7 @@ end it "includes options for proxy support" do - expect(HTTParty).to receive(:get) + allow(HTTParty).to receive(:get) .with( "#{subject.base_url}test", format: :json, @@ -183,7 +183,7 @@ end it "supports custom user agent" do - expect(HTTParty).to receive(:get) + allow(HTTParty).to receive(:get) .with( "#{subject.base_url}test", format: :json, From e84b9a1b326c76fca81d10709c0ae56d6f0c4e54 Mon Sep 17 00:00:00 2001 From: Santiago Traversa Date: Tue, 20 Apr 2021 23:28:21 -0300 Subject: [PATCH 03/13] Update .rubocop_todo.yml --- .rubocop_todo.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 16f9a6ab..0ece6377 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-04-21 02:13:15 UTC using RuboCop version 1.12.1. +# on 2021-04-21 02:26:31 UTC using RuboCop version 1.12.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -24,13 +24,13 @@ RSpec/LeakyConstantDeclaration: Exclude: - 'spec/dnsimple/client/client_service_spec.rb' -# Offense count: 21 +# Offense count: 11 # Configuration parameters: . # SupportedStyles: have_received, receive RSpec/MessageSpies: EnforcedStyle: receive -# Offense count: 117 +# Offense count: 112 RSpec/MultipleExpectations: Max: 15 From 7108c7e21bae524d7be760dedc2db100911b1f22 Mon Sep 17 00:00:00 2001 From: Santiago Traversa Date: Wed, 21 Apr 2021 10:33:33 -0300 Subject: [PATCH 04/13] [RSpec/ContextWording] Fixed Start context description with 'when', 'with', or 'without' --- .rubocop_todo.yml | 10 +--------- spec/dnsimple/client/domains_collaborators_spec.rb | 4 ++-- spec/dnsimple/options/list_options_spec.rb | 8 ++++---- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0ece6377..342e8353 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,19 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-04-21 02:26:31 UTC using RuboCop version 1.12.1. +# on 2021-04-21 02:53:46 UTC using RuboCop version 1.12.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 6 -# Configuration parameters: Prefixes. -# Prefixes: when, with, without -RSpec/ContextWording: - Exclude: - - 'spec/dnsimple/client/domains_collaborators_spec.rb' - - 'spec/dnsimple/options/list_options_spec.rb' - # Offense count: 71 # Configuration parameters: Max. RSpec/ExampleLength: diff --git a/spec/dnsimple/client/domains_collaborators_spec.rb b/spec/dnsimple/client/domains_collaborators_spec.rb index 30664c9a..8e1c117b 100644 --- a/spec/dnsimple/client/domains_collaborators_spec.rb +++ b/spec/dnsimple/client/domains_collaborators_spec.rb @@ -63,7 +63,7 @@ let(:account_id) { 1010 } let(:domain_id) { "example.com" } - context "invite user already registered on DNSimple" do + context "when inviting a user already registered on DNSimple" do before do stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/collaborators$}) .to_return(read_http_fixture("addCollaborator/success.http")) @@ -93,7 +93,7 @@ end end - context "invite not registered on DNSimple" do + context "when inviting a user not registered on DNSimple" do before do stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/collaborators$}) .to_return(read_http_fixture("addCollaborator/invite-success.http")) diff --git a/spec/dnsimple/options/list_options_spec.rb b/spec/dnsimple/options/list_options_spec.rb index de5276e6..d1c5249c 100644 --- a/spec/dnsimple/options/list_options_spec.rb +++ b/spec/dnsimple/options/list_options_spec.rb @@ -14,14 +14,14 @@ expect(options.to_h).to eq({}) end - context 'query' do + describe 'query' do it 'adds "query" key if given options are filled' do options = described_class.new(a: 1) expect(options.to_h).to have_key(:query) end end - context 'pagination' do + describe 'pagination' do it 'adds "page" to "query"' do raw = { page: '23' } expected = { query: raw } @@ -47,7 +47,7 @@ end end - context 'sorting' do + describe 'sorting' do it 'adds sorting policy to "query"' do raw = { sort: 'name:desc' } expected = { query: raw } @@ -73,7 +73,7 @@ end end - context 'filtering' do + describe 'filtering' do it 'adds filtering policy to "query"' do raw = { filter: { name_like: 'example' } } expected = { query: raw.fetch(:filter) } From 03d84317bd60068ca617e2d5da766573f1e12ee1 Mon Sep 17 00:00:00 2001 From: Santiago Traversa Date: Wed, 21 Apr 2021 12:03:46 -0300 Subject: [PATCH 05/13] Update to Rubocop 1.13.0 --- .rubocop_todo.yml | 2 +- Gemfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 342e8353..6158004a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-04-21 02:53:46 UTC using RuboCop version 1.12.1. +# on 2021-04-21 14:55:39 UTC using RuboCop version 1.13.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new diff --git a/Gemfile b/Gemfile index 20e631ea..106b56a4 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ source 'https://rubygems.org' gemspec gem 'coveralls', require: false -gem 'rubocop', '1.12.1', require: false +gem 'rubocop', '1.13.0', require: false gem 'rubocop-performance', require: false gem 'rubocop-rake', require: false gem 'rubocop-rspec', require: false From 49ff148a36ae839151182de849713558f16604e5 Mon Sep 17 00:00:00 2001 From: Santiago Traversa Date: Thu, 22 Apr 2021 19:27:05 -0300 Subject: [PATCH 06/13] Removes support for EOL rubies v2.4 and v2.5 Ruby 2.5 status: eol release date: 2017-12-25 EOL date: 2021-03-31 Ruby 2.4 status: eol release date: 2016-12-25 EOL date: 2020-03-31 --- .travis.yml | 2 -- CHANGELOG.md | 2 ++ dnsimple.gemspec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 65dbba23..ec4071d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: ruby rvm: - - 2.4 - - 2.5 - 2.6 - 2.7 - 3.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index a42e58d2..7b2d667e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This project uses [Semantic Versioning 2.0.0](http://semver.org/). ## main +- CHANGED: Minimum Ruby version is now 2.6 + ## 6.0.0 - NEW: Added `registrar.get_domain_prices` to retrieve whether a domain is premium and the prices to register, transfer, and renew. (dnsimple/dnsimple-ruby#230) diff --git a/dnsimple.gemspec b/dnsimple.gemspec index 1faa543d..f3885f18 100644 --- a/dnsimple.gemspec +++ b/dnsimple.gemspec @@ -11,7 +11,7 @@ Gem::Specification.new do |s| s.summary = 'The DNSimple API client for Ruby' s.description = 'The DNSimple API client for Ruby.' - s.required_ruby_version = ">= 2.4" + s.required_ruby_version = ">= 2.6" s.require_paths = ['lib'] s.files = `git ls-files`.split("\n") From e71f7ca501808bb1da3f121915c32d93310d3197 Mon Sep 17 00:00:00 2001 From: Santiago Traversa Date: Thu, 22 Apr 2021 19:38:38 -0300 Subject: [PATCH 07/13] [Corrected] Lint/RedundantDirGlobSort Remove redundant sort. --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0cd8add3..68a85d57 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,4 +14,4 @@ SPEC_ROOT = File.expand_path(__dir__) end -Dir[File.join(SPEC_ROOT, "support/**/*.rb")].sort.each { |f| require f } +Dir[File.join(SPEC_ROOT, "support/**/*.rb")].each { |f| require f } From 39cbb453363ecca37b2d916bed5f9f4ff05b4aa4 Mon Sep 17 00:00:00 2001 From: Santiago Traversa Date: Thu, 22 Apr 2021 19:50:07 -0300 Subject: [PATCH 08/13] Have Travis run on 18.04 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ec4071d1..2bbe3fb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +dist: bionic + language: ruby rvm: From 22b6382c05796f43d1edbf020e910a2e95127224 Mon Sep 17 00:00:00 2001 From: Santiago Traversa Date: Thu, 22 Apr 2021 19:56:08 -0300 Subject: [PATCH 09/13] Update Gemfile --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 106b56a4..e1cb3c4d 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,6 @@ gemspec gem 'coveralls', require: false gem 'rubocop', '1.13.0', require: false -gem 'rubocop-performance', require: false +gem 'rubocop-performance', '1.11.0', require: false gem 'rubocop-rake', require: false gem 'rubocop-rspec', require: false From a679e8e66507a4e2fe1e8ab377129870511bdcb1 Mon Sep 17 00:00:00 2001 From: Santiago Traversa Date: Thu, 22 Apr 2021 20:24:27 -0300 Subject: [PATCH 10/13] Skips Lint/NonDeterministicRequireOrder in Ruby 2.x --- .rubocop.yml | 4 ++++ Gemfile | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 104f8bcb..3bc65498 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -26,3 +26,7 @@ Style/IfUnlessModifier: # with Ruby 2.3. Because we are supporting Ruby 2.0+ we can't use this operator. Style/SafeNavigation: Enabled: false + +# This rule conflicts with our specs codebase using Ruby 2.x and 3.x +Lint/NonDeterministicRequireOrder: + Enabled: false diff --git a/Gemfile b/Gemfile index e1cb3c4d..106b56a4 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,6 @@ gemspec gem 'coveralls', require: false gem 'rubocop', '1.13.0', require: false -gem 'rubocop-performance', '1.11.0', require: false +gem 'rubocop-performance', require: false gem 'rubocop-rake', require: false gem 'rubocop-rspec', require: false From 31a12063b73e91708d2e6021a51a822d56deacf7 Mon Sep 17 00:00:00 2001 From: Santiago Traversa Date: Thu, 22 Apr 2021 20:25:26 -0300 Subject: [PATCH 11/13] [Corrected] Style/SafeNavigation Use safe navigation (&.) instead of checking if an object exists before calling the method --- .rubocop.yml | 5 ----- lib/dnsimple/error.rb | 2 +- lib/dnsimple/extra.rb | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3bc65498..ff92010b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -22,11 +22,6 @@ Lint/Loop: Style/IfUnlessModifier: Enabled: false -# This rule suggest to use safe navigation (&.) operator which was introduced -# with Ruby 2.3. Because we are supporting Ruby 2.0+ we can't use this operator. -Style/SafeNavigation: - Enabled: false - # This rule conflicts with our specs codebase using Ruby 2.x and 3.x Lint/NonDeterministicRequireOrder: Enabled: false diff --git a/lib/dnsimple/error.rb b/lib/dnsimple/error.rb index de89d5af..48d51268 100644 --- a/lib/dnsimple/error.rb +++ b/lib/dnsimple/error.rb @@ -18,7 +18,7 @@ def initialize(http_response) def message_from(http_response) content_type = http_response.headers["Content-Type"] - if content_type && content_type.start_with?("application/json") + if content_type&.start_with?("application/json") http_response.parsed_response["message"] else net_http_response = http_response.response diff --git a/lib/dnsimple/extra.rb b/lib/dnsimple/extra.rb index 8458801d..5b8fafbf 100644 --- a/lib/dnsimple/extra.rb +++ b/lib/dnsimple/extra.rb @@ -55,7 +55,7 @@ def self.deep_merge!(this, other, &block) # @raise [ArgumentError] def self.validate_mandatory_attributes(attributes, required) required.each do |name| - attributes && attributes.key?(name) or raise(ArgumentError, ":#{name} is required") + attributes&.key?(name) or raise(ArgumentError, ":#{name} is required") end end From 3bbf88a5eb010ad30e47dfa96992b52444eafc9f Mon Sep 17 00:00:00 2001 From: Santiago Traversa Date: Thu, 22 Apr 2021 20:26:16 -0300 Subject: [PATCH 12/13] Removes unused Style/IfUnlessModifier setting --- .rubocop.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ff92010b..25da33f6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,10 +18,6 @@ AllCops: Lint/Loop: Enabled: false -# It doesn't seem to work as expected. -Style/IfUnlessModifier: - Enabled: false - # This rule conflicts with our specs codebase using Ruby 2.x and 3.x Lint/NonDeterministicRequireOrder: Enabled: false From a78deaaa1b01eef0fa0ae75f33c05605a3c39f90 Mon Sep 17 00:00:00 2001 From: Santiago Traversa Date: Thu, 22 Apr 2021 20:27:21 -0300 Subject: [PATCH 13/13] [Corrected] Layout/IndentationConsistency Inconsistent indentation detected --- .rubocop.yml | 6 ------ lib/dnsimple/client/clients.rb | 5 +++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 25da33f6..08fe339f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,12 +12,6 @@ AllCops: - '*.gemspec' - 'Rakefile' -# [codesmell] -# It's irrelevant here, but it could be a code smell. -# Hence keep it disabled, but don't include it in the DNSimple suite. -Lint/Loop: - Enabled: false - # This rule conflicts with our specs codebase using Ruby 2.x and 3.x Lint/NonDeterministicRequireOrder: Enabled: false diff --git a/lib/dnsimple/client/clients.rb b/lib/dnsimple/client/clients.rb index 5d569181..437814ce 100644 --- a/lib/dnsimple/client/clients.rb +++ b/lib/dnsimple/client/clients.rb @@ -98,14 +98,15 @@ def paginate(method, *args) options = args.pop response = nil - begin + loop do current_page += 1 query = Extra.deep_merge(options, query: { page: current_page, per_page: 100 }) response = send(method, *(args + [query])) total_pages ||= response.total_pages collection.concat(response.data) - end while current_page < total_pages + break unless current_page < total_pages + end CollectionResponse.new(response.http_response, collection) end