spec/slack/web/api/pagination/cursor_spec.rb in slack-ruby-client-0.17.0 vs spec/slack/web/api/pagination/cursor_spec.rb in slack-ruby-client-1.0.0

- old
+ new

@@ -28,11 +28,11 @@ ) expect(cursor).not_to receive(:sleep) cursor.to_a end context 'with rate limiting' do - let(:error) { Slack::Web::Api::Errors::TooManyRequestsError.new(nil) } + let(:error) { Slack::Web::Api::Errors::TooManyRequestsError.new(OpenStruct.new(headers: { 'retry-after' => 9 })) } context 'with default max retries' do it 'sleeps after a TooManyRequestsError' do expect(client).to( receive(:users_list) @@ -41,11 +41,10 @@ .and_return(Slack::Messages::Message.new(response_metadata: { next_cursor: 'next' })) ) expect(client).to( receive(:users_list).with(limit: 100, cursor: 'next').ordered.and_raise(error) ) - expect(error).to receive(:retry_after).once.ordered.and_return(9) expect(cursor).to receive(:sleep).once.ordered.with(9) expect(client).to( receive(:users_list) .with(limit: 100, cursor: 'next') .ordered @@ -65,10 +64,9 @@ .and_return(Slack::Messages::Message.new(response_metadata: { next_cursor: 'next' })) ) expect(client).to( receive(:users_list).with(limit: 100, cursor: 'next').exactly(5).times.and_raise(error) ) - expect(error).to receive(:retry_after).exactly(4).times.and_return(9) expect(cursor).to receive(:sleep).exactly(4).times.with(9) expect { cursor.to_a }.to raise_error(error) end end end