From cf4b80ce308a1e5042adbe6da895f2e2b14efed9 Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Wed, 2 Feb 2022 12:27:05 -0800 Subject: [PATCH 1/9] Start switching to double splats (tests still broken) --- .../customizations/object_summary.rb | 18 +++++++++--------- .../aws-sdk-s3/multipart_stream_uploader.rb | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb b/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb index 94565f01cee..7e306ffe891 100644 --- a/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb +++ b/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb @@ -14,7 +14,7 @@ class ObjectSummary # @return (see Object#copy_from) # @see Object#copy_from def copy_from(source, options = {}) - object.copy_from(source, options) + object.copy_from(source, **options) end # @param (see Object#copy_to) @@ -22,7 +22,7 @@ def copy_from(source, options = {}) # @return (see Object#copy_to) # @see Object#copy_to def copy_to(target, options = {}) - object.copy_to(target, options) + object.copy_to(target, **options) end # @param (see Object#move_to) @@ -30,7 +30,7 @@ def copy_to(target, options = {}) # @return (see Object#move_to) # @see Object#move_to def move_to(target, options = {}) - object.move_to(target, options) + object.move_to(target, **options) end # @param (see Object#presigned_post) @@ -38,7 +38,7 @@ def move_to(target, options = {}) # @return (see Object#presigned_post) # @see Object#presigned_post def presigned_post(options = {}) - object.presigned_post(options) + object.presigned_post(**options) end # @param (see Object#presigned_url) @@ -46,7 +46,7 @@ def presigned_post(options = {}) # @return (see Object#presigned_url) # @see Object#presigned_url def presigned_url(http_method, params = {}) - object.presigned_url(http_method, params) + object.presigned_url(http_method, **params) end # @param (see Object#public_url) @@ -54,7 +54,7 @@ def presigned_url(http_method, params = {}) # @return (see Object#public_url) # @see Object#public_url def public_url(options = {}) - object.public_url(options) + object.public_url(**options) end # @param (see Object#upload_file) @@ -62,14 +62,14 @@ def public_url(options = {}) # @return (see Object#upload_file) # @see Object#upload_file def upload_file(source, options = {}) - object.upload_file(source, options) + object.upload_file(source, **options) end # @options (see Object#upload_stream) # @return (see Object#upload_stream) # @see Object#upload_stream def upload_stream(options = {}, &block) - object.upload_stream(options, &block) + object.upload_stream(**options, &block) end # @param (see Object#download_file) @@ -77,7 +77,7 @@ def upload_stream(options = {}, &block) # @return (see Object#download_file) # @see Object#download_file def download_file(destination, options = {}) - object.download_file(destination, options) + object.download_file(destination, **options) end end diff --git a/gems/aws-sdk-s3/lib/aws-sdk-s3/multipart_stream_uploader.rb b/gems/aws-sdk-s3/lib/aws-sdk-s3/multipart_stream_uploader.rb index 9c2e085e5cf..36230b3c4f8 100644 --- a/gems/aws-sdk-s3/lib/aws-sdk-s3/multipart_stream_uploader.rb +++ b/gems/aws-sdk-s3/lib/aws-sdk-s3/multipart_stream_uploader.rb @@ -146,7 +146,7 @@ def upload_in_threads(read_pipe, completed, options) body: body, part_number: thread_part_number, ) - resp = @client.upload_part(part) + resp = @client.upload_part(**part) completed << {etag: resp.etag, part_number: part[:part_number]} ensure if Tempfile === body From 1324c8d296c763739d78cccab4bd4f2144744b59 Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Fri, 4 Feb 2022 10:43:12 -0800 Subject: [PATCH 2/9] Revert "Start switching to double splats (tests still broken)" This reverts commit cf4b80ce308a1e5042adbe6da895f2e2b14efed9. --- .../customizations/object_summary.rb | 18 +++++++++--------- .../aws-sdk-s3/multipart_stream_uploader.rb | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb b/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb index 7e306ffe891..94565f01cee 100644 --- a/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb +++ b/gems/aws-sdk-s3/lib/aws-sdk-s3/customizations/object_summary.rb @@ -14,7 +14,7 @@ class ObjectSummary # @return (see Object#copy_from) # @see Object#copy_from def copy_from(source, options = {}) - object.copy_from(source, **options) + object.copy_from(source, options) end # @param (see Object#copy_to) @@ -22,7 +22,7 @@ def copy_from(source, options = {}) # @return (see Object#copy_to) # @see Object#copy_to def copy_to(target, options = {}) - object.copy_to(target, **options) + object.copy_to(target, options) end # @param (see Object#move_to) @@ -30,7 +30,7 @@ def copy_to(target, options = {}) # @return (see Object#move_to) # @see Object#move_to def move_to(target, options = {}) - object.move_to(target, **options) + object.move_to(target, options) end # @param (see Object#presigned_post) @@ -38,7 +38,7 @@ def move_to(target, options = {}) # @return (see Object#presigned_post) # @see Object#presigned_post def presigned_post(options = {}) - object.presigned_post(**options) + object.presigned_post(options) end # @param (see Object#presigned_url) @@ -46,7 +46,7 @@ def presigned_post(options = {}) # @return (see Object#presigned_url) # @see Object#presigned_url def presigned_url(http_method, params = {}) - object.presigned_url(http_method, **params) + object.presigned_url(http_method, params) end # @param (see Object#public_url) @@ -54,7 +54,7 @@ def presigned_url(http_method, params = {}) # @return (see Object#public_url) # @see Object#public_url def public_url(options = {}) - object.public_url(**options) + object.public_url(options) end # @param (see Object#upload_file) @@ -62,14 +62,14 @@ def public_url(options = {}) # @return (see Object#upload_file) # @see Object#upload_file def upload_file(source, options = {}) - object.upload_file(source, **options) + object.upload_file(source, options) end # @options (see Object#upload_stream) # @return (see Object#upload_stream) # @see Object#upload_stream def upload_stream(options = {}, &block) - object.upload_stream(**options, &block) + object.upload_stream(options, &block) end # @param (see Object#download_file) @@ -77,7 +77,7 @@ def upload_stream(options = {}, &block) # @return (see Object#download_file) # @see Object#download_file def download_file(destination, options = {}) - object.download_file(destination, **options) + object.download_file(destination, options) end end diff --git a/gems/aws-sdk-s3/lib/aws-sdk-s3/multipart_stream_uploader.rb b/gems/aws-sdk-s3/lib/aws-sdk-s3/multipart_stream_uploader.rb index 36230b3c4f8..9c2e085e5cf 100644 --- a/gems/aws-sdk-s3/lib/aws-sdk-s3/multipart_stream_uploader.rb +++ b/gems/aws-sdk-s3/lib/aws-sdk-s3/multipart_stream_uploader.rb @@ -146,7 +146,7 @@ def upload_in_threads(read_pipe, completed, options) body: body, part_number: thread_part_number, ) - resp = @client.upload_part(**part) + resp = @client.upload_part(part) completed << {etag: resp.etag, part_number: part[:part_number]} ensure if Tempfile === body From f88d3f48e97b1956753207aed9e0a89af955472b Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Fri, 4 Feb 2022 10:43:28 -0800 Subject: [PATCH 3/9] Start updating rspec mocks with hash syntax --- .../spec/object/upload_stream_spec.rb | 12 ++++----- gems/aws-sdk-s3/spec/object_summary_spec.rb | 25 ++++++++++++------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/gems/aws-sdk-s3/spec/object/upload_stream_spec.rb b/gems/aws-sdk-s3/spec/object/upload_stream_spec.rb index efe3fe76727..edfa1b8a182 100644 --- a/gems/aws-sdk-s3/spec/object/upload_stream_spec.rb +++ b/gems/aws-sdk-s3/spec/object/upload_stream_spec.rb @@ -309,27 +309,27 @@ module S3 body: instance_of(Tempfile), part_number: 1 ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(Tempfile), part_number: 2 - ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + }).once.and_return(double(:upload_part, etag: 'etag')) + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(Tempfile), part_number: 3 - ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + }).once.and_return(double(:upload_part, etag: 'etag')) + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(Tempfile), part_number: 4 - ).once.and_return(double(:upload_part, etag: 'etag')) + }).once.and_return(double(:upload_part, etag: 'etag')) object.upload_stream(tempfile: true) do |write_stream| write_stream << seventeen_mb end diff --git a/gems/aws-sdk-s3/spec/object_summary_spec.rb b/gems/aws-sdk-s3/spec/object_summary_spec.rb index 604c16c5a7f..e2ed802c447 100644 --- a/gems/aws-sdk-s3/spec/object_summary_spec.rb +++ b/gems/aws-sdk-s3/spec/object_summary_spec.rb @@ -21,55 +21,62 @@ module S3 it 'delegates #copy_from to #object' do expect(object).to receive(:copy_from) - .with('source', opt_name: 'opt-value') + .with('source', { opt_name: 'opt-value' }) object_summary.copy_from('source', opt_name: 'opt-value') end + it 'fails' do + object = double('object') + expect(object).to receive(:copy_from) + .with('source', opt_name: 'opt-value') + object.copy_from('source', opt_name: 'opt-value') + end + it 'delegates #copy_to to #object' do expect(object).to receive(:copy_to) - .with('target', opt_name: 'opt-value') + .with('target', { opt_name: 'opt-value' }) object_summary.copy_to('target', opt_name: 'opt-value') end it 'delegates #move_to to #object' do expect(object).to receive(:move_to) - .with('target', opt_name: 'opt-value') + .with('target', { opt_name: 'opt-value' }) object_summary.move_to('target', opt_name: 'opt-value') end it 'delegates #presigned_post to #object' do expect(object).to receive(:presigned_post) - .with(opt_name: 'opt-value') + .with({ opt_name: 'opt-value' }) object_summary.presigned_post(opt_name: 'opt-value') end it 'delegates #presigned_url to #object' do expect(object).to receive(:presigned_url) - .with('method', opt_name: 'opt-value') + .with('method', { opt_name: 'opt-value' }) object_summary.presigned_url('method', opt_name: 'opt-value') end it 'delegates #public_url to #object' do - expect(object).to receive(:public_url).with(opt_name: 'opt-value') + expect(object).to receive(:public_url).with({ opt_name: 'opt-value' }) object_summary.public_url(opt_name: 'opt-value') end it 'delegates #upload_file to #object' do expect(object).to receive(:upload_file) - .with('source', opt_name: 'opt-value') + .with('source', { opt_name: 'opt-value'}) object_summary.upload_file('source', opt_name: 'opt-value') end it 'delegates #upload_stream to #object' do block = proc { :foo } expect(object).to receive(:upload_stream) - .with(opt_name: 'opt-value', &block) + .with({ opt_name: 'opt-value' }, &block) object_summary.upload_stream(opt_name: 'opt-value', &block) end it 'delegates #download_file to #object' do expect(object).to receive(:download_file) - .with('destination', opt_name: 'opt-value') + .with('destination', { opt_name: 'opt-value' }) object_summary.download_file('destination', opt_name: 'opt-value') end end From bc301d179e7f82b0110d69fea76808c64c7b63f1 Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Mon, 14 Feb 2022 12:43:52 -0800 Subject: [PATCH 4/9] Fix resources spec --- .../spec/interfaces/resources_spec.rb | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/build_tools/aws-sdk-code-generator/spec/interfaces/resources_spec.rb b/build_tools/aws-sdk-code-generator/spec/interfaces/resources_spec.rb index 773ca31f106..b0713b1caf2 100644 --- a/build_tools/aws-sdk-code-generator/spec/interfaces/resources_spec.rb +++ b/build_tools/aws-sdk-code-generator/spec/interfaces/resources_spec.rb @@ -31,7 +31,7 @@ it 'constructs a client using options given' do client = double('client') expect(Sample::Client).to receive(:new). - with(region: 'us-west-2'). + with({region: 'us-west-2'}). and_return(client) svc = Sample::Resource.new(region: 'us-west-2') expect(svc.client).to be(client) @@ -49,7 +49,7 @@ it 'supports actions returning a client response' do data = client.stub_data(:get_band) - expect(client).to receive(:get_band).with(foo:'bar'). + expect(client).to receive(:get_band).with({foo:'bar'}). and_return(double('resp', data: data)) svc = Sample::Resource.new(client: client) expect(svc.get_summary(foo: 'bar')).to be(data) @@ -57,7 +57,7 @@ it 'supports actions returning another resource' do data = client.stub_data(:create_band, band:{band_name:'abc'}) - expect(client).to receive(:create_band).with(band_name:'abc'). + expect(client).to receive(:create_band).with({band_name:'abc'}). and_return(double('resp', data: data)) svc = Sample::Resource.new(client: client) band = svc.create_band(band_name:'abc') @@ -243,7 +243,7 @@ it 'constructs a client from options' do client = double('client') expect(Sample::Client).to receive(:new). - with(region:'us-west-2'). + with({region:'us-west-2'}). and_return(client) band = Sample::Band.new(name:'name', region: 'us-west-2') expect(band.client).to be(client) @@ -251,7 +251,7 @@ it 'passes extra options to the client constructor' do client = double('client') - expect(Sample::Client).to receive(:new).with(foo:'bar').and_return(client) + expect(Sample::Client).to receive(:new).with({foo:'bar'}).and_return(client) band = Sample::Band.new(name:'name', data: double('data'), foo: 'bar') expect(band.client).to be(client) end @@ -451,7 +451,7 @@ it 'supports actions returning a client response' do data = client.stub_data(:update_band, {}) expect(client).to receive(:update_band). - with(band_name: 'name', bio: 'updated-band-bio'). + with({band_name: 'name', bio: 'updated-band-bio'}). and_return(double('resp', data: data)) band = Sample::Band.new(name:'name', client: client) expect(band.update(bio: 'updated-band-bio')).to be(data) @@ -463,7 +463,7 @@ cover_band_for: 'The Who', }) expect(client).to receive(:create_band). - with(band_name: 'Horton Heard a Who', cover_band_for: 'The Who'). + with({band_name: 'Horton Heard a Who', cover_band_for: 'The Who'}). and_return(double('resp', data: data)) band = Sample::Band.new(name:'The Who', client: client) @@ -487,13 +487,13 @@ end it 'supports actions that construct a batch from request params' do - expect(client).to receive(:create_tags).with( + expect(client).to receive(:create_tags).with({ resources: ['band-name'], tags: [ { key: 'tag-1-key', value: 'tag-1-value' }, { key: 'tag-2-key', value: 'tag-2-value' }, ] - ).and_return(double('resp', data: Aws::EmptyStructure.new)) + }).and_return(double('resp', data: Aws::EmptyStructure.new)) band = Sample::Band.new(name:'band-name', client: client) tags = band.create_tags(tags: [ { key: 'tag-1-key', value: 'tag-1-value' }, @@ -583,7 +583,7 @@ { fans: [{ name: 'fan-2' }] }, ]) expect(client).to receive(:list_fans). - with(favorite_band_name:'name'). + with({favorite_band_name:'name'}). and_call_original band = Sample::Band.new(name: 'name', client: client) fans = band.fans.to_a # force enumeration @@ -603,13 +603,13 @@ { name: 'fan-1' }, { name: 'fan-2' }, ]}) - expect(client).to receive(:list_fans).with( + expect(client).to receive(:list_fans).with({ filters: [ { name: 'favorite-band-name', values: ['band-name'] }, { name: 'fandom-level', values: ['AAA'] }, ], limit: 5 - ).and_call_original + }).and_call_original band = Sample::Band.new(name: 'band-name', client: client) band.biggest_fans.to_a # force enumeration end @@ -619,13 +619,13 @@ { name: 'fan-1' }, { name: 'fan-2' }, ]}) - expect(client).to receive(:list_fans).with( + expect(client).to receive(:list_fans).with({ filters: [ { name: 'favorite-band-name', values: ['band-name'] }, { name: 'fandom-level', values: ['AAA'] }, ], limit: 5 - ).and_call_original + }).and_call_original band = Sample::Band.new(name: 'band-name', client: client) band.biggest_fans.to_a # force enumeration end @@ -635,14 +635,14 @@ # Aws::EC2::Client#describe_instances has a list of filter objets # with keys and values. The has many association requires lists # to be appended to each other for a proper merge. - expect(client).to receive(:list_fans).with( + expect(client).to receive(:list_fans).with({ filters: [ { name: 'favorite-band-name', values: ['band-name'] }, { name: 'fandom-level', values: ['AAA'] }, { name: 'location', values: ['Seattle', 'Tacoma'] }, ], limit: 5 - ).and_call_original + }).and_call_original band = Sample::Band.new(name: 'band-name', client: client) band.biggest_fans( filters: [ @@ -673,32 +673,32 @@ it 'invokes the appropriate waiter' do waiter = double('waiter') expect(Sample::Waiters::BandExists).to receive(:new). - with(client: client). + with({client: client}). and_return(waiter) - expect(waiter).to receive(:wait).with(band_name: 'band-name') + expect(waiter).to receive(:wait).with({band_name: 'band-name'}) band = Sample::Band.new(name: 'band-name', client: client) band.wait_until_exists end it 'accepts configuration options' do waiter = double('waiter') - expect(Sample::Waiters::BandExists).to receive(:new).with( + expect(Sample::Waiters::BandExists).to receive(:new).with({ client: client, max_attempts: 2, delay: 2, - ).and_return(waiter) - expect(waiter).to receive(:wait).with(band_name: 'band-name') + }).and_return(waiter) + expect(waiter).to receive(:wait).with({band_name: 'band-name'}) band = Sample::Band.new(name: 'band-name', client: client) band.wait_until_exists(max_attempts: 2, delay: 2) end it 'passes through params to the client waiter method' do waiter = double('waiter') - expect(Sample::Waiters::BandExists).to receive(:new).with( + expect(Sample::Waiters::BandExists).to receive(:new).with({ client: client, max_attempts: 1, - ).and_return(waiter) - expect(waiter).to receive(:wait).with(band_name: 'band-name', extra_param: true) + }).and_return(waiter) + expect(waiter).to receive(:wait).with({band_name: 'band-name', extra_param: true}) band = Sample::Band.new(name: 'band-name', client: client) band.exists?(extra_param: true) end @@ -715,9 +715,9 @@ it 'returns a new unhydrated resource if path is not given' do waiter = double('waiter') expect(Sample::Waiters::BandExists).to receive(:new). - with(client: client). + with({client: client}). and_return(waiter) - expect(waiter).to receive(:wait).with(band_name: 'band-name') + expect(waiter).to receive(:wait).with({band_name: 'band-name'}) band = Sample::Band.new(name: 'band-name', client: client) result = band.wait_until_exists expect(result).to be_kind_of(Sample::Band) @@ -741,10 +741,10 @@ { bands: [{ band_name: 'band-2' }] }, ]) expect(client).to receive(:delete_bands). - with(bands: [{ band_name: 'band-1' }]). + with({bands: [{ band_name: 'band-1' }]}). ordered expect(client).to receive(:delete_bands). - with(bands: [{ band_name: 'band-2' }]). + with({bands: [{ band_name: 'band-2' }]}). ordered svc = Sample::Resource.new(client: client) bands = svc.bands @@ -756,12 +756,12 @@ { bands: [{ band_name: 'band-1' }], next_token: 'token' }, { bands: [{ band_name: 'band-2' }] }, ]) - expect(client).to receive(:create_tags).with( + expect(client).to receive(:create_tags).with({ resources: ['band-1'], tags:[{ key: 'tag-1-key', value: 'tag-1-value' }] - ).ordered - expect(client).to receive(:create_tags).with( + }).ordered + expect(client).to receive(:create_tags).with({ resources: ['band-2'], tags:[{ key: 'tag-1-key', value: 'tag-1-value' }] - ).ordered + }).ordered svc = Sample::Resource.new(client: client) bands = svc.bands bands.batch_create_tags(tags:[ @@ -775,10 +775,10 @@ { bands: [{ band_name: 'band-2' }] }, ]) expect(client).to receive(:delete_bands). - with(bands: [{ band_name: 'band-1' }]). + with({bands: [{ band_name: 'band-1' }]}). ordered expect(client).to receive(:delete_bands). - with(bands: [{ band_name: 'band-2' }]). + with({bands: [{ band_name: 'band-2' }]}). ordered svc = Sample::Resource.new(client: client) bands = svc.bands From 34207735c614e4a530e657905a73f3cd76b25af0 Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Mon, 14 Feb 2022 13:53:14 -0800 Subject: [PATCH 5/9] Multipart copy spec passing --- .../spec/object/multipart_copy_spec.rb | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/gems/aws-sdk-s3/spec/object/multipart_copy_spec.rb b/gems/aws-sdk-s3/spec/object/multipart_copy_spec.rb index 954bea2a6f3..af814650e38 100644 --- a/gems/aws-sdk-s3/spec/object/multipart_copy_spec.rb +++ b/gems/aws-sdk-s3/spec/object/multipart_copy_spec.rb @@ -13,39 +13,39 @@ module S3 describe '#copy_to' do it 'accepts a string source' do - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'target-bucket', key: 'target-key', copy_source: 'bucket/unescaped/key%20path' - ) + }) object.copy_to('target-bucket/target-key') end it 'accepts a hash source' do - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'target-bucket', key: 'target-key', copy_source: 'bucket/unescaped/key%20path' - ) + }) object.copy_to(bucket: 'target-bucket', key: 'target-key') end it 'accepts a hash source' do - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'target-bucket', key: 'target-key', copy_source: 'bucket/unescaped/key%20path' - ) + }) object.copy_to(bucket: 'target-bucket', key: 'target-key') end it 'accept a hash with options merged' do - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'target-bucket', key: 'target-key', copy_source: 'bucket/unescaped/key%20path', content_type: 'text/plain' - ) + }) object.copy_to( bucket: 'target-bucket', key: 'target-key', @@ -54,11 +54,11 @@ module S3 end it 'accepts an S3::Object source' do - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'target-bucket', key: 'target-key', copy_source: 'bucket/unescaped/key%20path' - ) + }) target = S3::Object.new( 'target-bucket', 'target-key', @@ -68,12 +68,12 @@ module S3 end it 'accepts additional options' do - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'target-bucket', key: 'target-key', copy_source: 'bucket/unescaped/key%20path', acl: 'public-read' - ) + }) object.copy_to('target-bucket/target-key', acl: 'public-read') end @@ -85,31 +85,31 @@ module S3 describe '#copy_from' do context 'with multipart_copy: false' do it 'supports the deprecated form' do - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'bucket', key: 'unescaped/key path', copy_source: 'source-bucket/escaped/source/key%20path' - ) + }) object.copy_from( copy_source: 'source-bucket/escaped/source/key%20path' ) end it 'accepts a string source' do - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'bucket', key: 'unescaped/key path', copy_source: 'source-bucket/source/key%20path' - ) + }) object.copy_from('source-bucket/source/key%20path') end it 'accepts a hash source' do - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'bucket', key: 'unescaped/key path', copy_source: 'source-bucket/unescaped/source/key%20path' - ) + }) object.copy_from( bucket: 'source-bucket', key: 'unescaped/source/key path' @@ -117,11 +117,11 @@ module S3 end it 'accepts a hash source with version id' do - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'bucket', key: 'unescaped/key path', copy_source: 'src-bucket/src%20key?versionId=src-version-id' - ) + }) object.copy_from( bucket: 'src-bucket', key: 'src key', @@ -130,12 +130,12 @@ module S3 end it 'accept a hash with options merged' do - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'bucket', key: 'unescaped/key path', copy_source: 'source-bucket/source%20key', content_type: 'text/plain' - ) + }) object.copy_from( bucket: 'source-bucket', key: 'source key', @@ -149,11 +149,11 @@ module S3 'unescaped/source/key path', stub_responses: true ) - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'bucket', key: 'unescaped/key path', copy_source: 'source-bucket/unescaped/source/key%20path' - ) + }) object.copy_from(src) end @@ -163,11 +163,11 @@ module S3 'unescaped/source/key path', stub_responses: true ) - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'bucket', key: 'unescaped/key path', copy_source: 'source-bucket/unescaped/source/key%20path' - ) + }) object.copy_from(src) end @@ -177,22 +177,22 @@ module S3 'source-version-id', stub_responses: true ) - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'bucket', key: 'unescaped/key path', copy_source: 'source-bucket/unescaped/source/key%20path'\ '?versionId=source-version-id' - ) + }) object.copy_from(src) end it 'accepts additional options' do - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'bucket', key: 'unescaped/key path', copy_source: 'source-bucket/source%20key', acl: 'public-read' - ) + }) object.copy_from('source-bucket/source%20key', acl: 'public-read') end @@ -204,16 +204,16 @@ module S3 context 'with version_id and multipart_copy: true' do before(:each) do size = 300 * 1024 * 1024 # 300MB - allow(client).to receive(:head_object).with( + allow(client).to receive(:head_object).with({ bucket: 'source-bucket', key: 'source key', version_id: 'source-version-id' - ).and_return(client.stub_data(:head_object, content_length: size)) + }).and_return(client.stub_data(:head_object, content_length: size)) end it 'performs multipart uploads for a versioned object' do expect(client).to receive(:create_multipart_upload) - .with(bucket: 'bucket', key: 'unescaped/key path') + .with({bucket: 'bucket', key: 'unescaped/key path'}) .and_return( client.stub_data(:create_multipart_upload, upload_id: 'id') ) @@ -223,14 +223,14 @@ module S3 (1..6).each do |n| range = "bytes=#{(n - 1) * 52_428_800}-#{n * 52_428_800 - 1}" - expect(client).to receive(:upload_part_copy).with( + expect(client).to receive(:upload_part_copy).with({ bucket: 'bucket', key: 'unescaped/key path', part_number: n, copy_source: source, copy_source_range: range, upload_id: 'id' - ).and_return( + }).and_return( client.stub_data( :upload_part_copy, copy_part_result: { etag: "etag#{n}" } @@ -238,14 +238,14 @@ module S3 ) end - expect(client).to receive(:complete_multipart_upload).with( + expect(client).to receive(:complete_multipart_upload).with({ bucket: 'bucket', key: 'unescaped/key path', upload_id: 'id', multipart_upload: { parts: (1..6).map { |n| { etag: "etag#{n}", part_number: n } } } - ) + }) object.copy_from(source, multipart_copy: true) end @@ -254,15 +254,15 @@ module S3 context 'with multipart_copy: true' do before(:each) do size = 300 * 1024 * 1024 # 300MB - allow(client).to receive(:head_object).with( + allow(client).to receive(:head_object).with({ bucket: 'source-bucket', key: 'source key' - ).and_return(client.stub_data(:head_object, content_length: size)) + }).and_return(client.stub_data(:head_object, content_length: size)) end it 'performs multipart uploads when :multipart_copy is true' do expect(client).to receive(:create_multipart_upload) - .with(bucket: 'bucket', key: 'unescaped/key path') + .with({bucket: 'bucket', key: 'unescaped/key path'}) .and_return( client.stub_data(:create_multipart_upload, upload_id: 'id') ) @@ -270,14 +270,14 @@ module S3 (1..6).each do |n| range = "bytes=#{(n - 1) * 52_428_800}-#{n * 52_428_800 - 1}" - expect(client).to receive(:upload_part_copy).with( + expect(client).to receive(:upload_part_copy).with({ bucket: 'bucket', key: 'unescaped/key path', part_number: n, copy_source: 'source-bucket/source%20key', copy_source_range: range, upload_id: 'id' - ).and_return( + }).and_return( client.stub_data( :upload_part_copy, copy_part_result: { etag: "etag#{n}" } @@ -285,14 +285,14 @@ module S3 ) end - expect(client).to receive(:complete_multipart_upload).with( + expect(client).to receive(:complete_multipart_upload).with({ bucket: 'bucket', key: 'unescaped/key path', upload_id: 'id', multipart_upload: { parts: (1..6).map { |n| { etag: "etag#{n}", part_number: n } } } - ) + }) object.copy_from('source-bucket/source%20key', multipart_copy: true) end @@ -366,16 +366,16 @@ module S3 it 'aborts the upload on errors', thread_report_on_exception: false do client.stub_responses(:upload_part_copy, Array.new(10, 'NoSuchKey')) allow(client).to receive(:create_multipart_upload) - .with(bucket: 'bucket', key: 'unescaped/key path') + .with({bucket: 'bucket', key: 'unescaped/key path'}) .and_return( client.stub_data(:create_multipart_upload, upload_id: 'id') ) expect(client).to receive(:abort_multipart_upload) - .with( + .with({ bucket: 'bucket', key: 'unescaped/key path', upload_id: 'id' - ) + }) expect do object.copy_from( 'source-bucket/source%20key', @@ -386,10 +386,10 @@ module S3 it 'rejects files smaller than 5MB' do size = 4 * 1024 * 1024 - allow(client).to receive(:head_object).with( + allow(client).to receive(:head_object).with({ bucket: 'source-bucket', key: 'source key' - ).and_return(client.stub_data(:head_object, content_length: size)) + }).and_return(client.stub_data(:head_object, content_length: size)) expect do object.copy_from( 'source-bucket/source%20key', @@ -446,7 +446,7 @@ module S3 context 'when the source is an S3::Object' do it 'uses the content-length of the source object and region' do expect(source_client).to receive(:head_object) - .with(bucket: source_bucket, key: key) + .with({bucket: source_bucket, key: key}) expect(target_client).not_to receive(:head_object) target_object.copy_from(source_object, multipart_copy: true) @@ -458,7 +458,7 @@ module S3 it 'uses :copy_source_client to query content_length' do expect(source_client).to receive(:head_object) - .with(bucket: source_bucket, key: key) + .with({bucket: source_bucket, key: key}) expect(target_client).not_to receive(:head_object) target_object.copy_from( @@ -474,7 +474,7 @@ module S3 hash_including(region: source_region) ).and_return(source_client) expect(source_client).to receive(:head_object) - .with(bucket: source_bucket, key: key) + .with({bucket: source_bucket, key: key}) expect(target_client).not_to receive(:head_object) target_object.copy_from( @@ -490,7 +490,7 @@ module S3 it 'uses :copy_source_client to query content_length' do expect(source_client).to receive(:head_object) - .with(bucket: source_bucket, key: key) + .with({bucket: source_bucket, key: key}) expect(target_client).not_to receive(:head_object) target_object.copy_from( @@ -507,7 +507,7 @@ module S3 hash_including(region: source_region) ).and_return(source_client) expect(source_client).to receive(:head_object) - .with(bucket: source_bucket, key: key) + .with({bucket: source_bucket, key: key}) expect(target_client).not_to receive(:head_object) target_object.copy_from( From 372ad87486b847d70e5fa75a265de7974f517842 Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Mon, 14 Feb 2022 14:09:58 -0800 Subject: [PATCH 6/9] Force rspec to new version --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index a0c09a92130..c5561bb08ca 100644 --- a/Gemfile +++ b/Gemfile @@ -27,7 +27,7 @@ group :test do gem 'webmock' gem 'multipart-post' - gem 'rspec' + gem 'rspec', '>= 3.11.0' end group :build do From c659fe3668a3410dfa6c9eee5fa359142241d1aa Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Mon, 14 Feb 2022 14:21:14 -0800 Subject: [PATCH 7/9] More fixes --- .../spec/object/download_file_spec.rb | 48 +++++++++---------- .../spec/object/presigned_url_spec.rb | 6 +-- .../spec/object/upload_file_spec.rb | 24 +++++----- 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/gems/aws-sdk-s3/spec/object/download_file_spec.rb b/gems/aws-sdk-s3/spec/object/download_file_spec.rb index 5d98e57926e..d2f90f3e657 100644 --- a/gems/aws-sdk-s3/spec/object/download_file_spec.rb +++ b/gems/aws-sdk-s3/spec/object/download_file_spec.rb @@ -54,11 +54,11 @@ module S3 before(:each) do allow(Dir).to receive(:tmpdir).and_return(tmpdir) - allow(client).to receive(:head_object).with( + allow(client).to receive(:head_object).with({ bucket: 'bucket', key: 'small', part_number: 1 - ).and_return( + }).and_return( client.stub_data( :head_object, content_length: one_meg, @@ -66,12 +66,12 @@ module S3 ) ) - allow(client).to receive(:head_object).with( + allow(client).to receive(:head_object).with({ bucket: 'bucket', key: 'small', part_number: 1, version_id: version_id - ).and_return( + }).and_return( client.stub_data( :head_object, content_length: one_meg, @@ -79,11 +79,11 @@ module S3 ) ) - allow(client).to receive(:head_object).with( + allow(client).to receive(:head_object).with({ bucket: 'bucket', key: 'large', part_number: 1 - ).and_return( + }).and_return( client.stub_data( :head_object, content_length: 5 * one_meg, @@ -91,21 +91,21 @@ module S3 ) ) - allow(client).to receive(:head_object).with( + allow(client).to receive(:head_object).with({ bucket: 'bucket', key: 'large' - ).and_return( + }).and_return( client.stub_data( :head_object, content_length: 20 * one_meg ) ) - allow(client).to receive(:head_object).with( + allow(client).to receive(:head_object).with({ bucket: 'bucket', key: 'single', part_number: 1 - ).and_return( + }).and_return( client.stub_data( :head_object, content_length: 15 * one_meg, @@ -115,42 +115,42 @@ module S3 end it 'downloads single part files in Client#get_object' do - expect(client).to receive(:get_object).with( + expect(client).to receive(:get_object).with({ bucket: 'bucket', key: 'small', response_target: path - ).exactly(1).times + }).exactly(1).times small_obj.download_file(path) end it 'download larger files in parts' do - expect(client).to receive(:head_object).with( + expect(client).to receive(:head_object).with({ bucket: 'bucket', key: 'large', part_number: 1 - ).exactly(1).times + }).exactly(1).times large_obj.download_file(path) end it 'download larger files in ranges' do - expect(client).to receive(:head_object).with( + expect(client).to receive(:head_object).with({ bucket: 'bucket', key: 'single', part_number: 1 - ).exactly(1).times + }).exactly(1).times single_obj.download_file(path) end it 'supports download object with version_id' do - expect(client).to receive(:get_object).with( + expect(client).to receive(:get_object).with({ bucket: 'bucket', key: 'small', version_id: version_id, response_target: path - ).exactly(1).times + }).exactly(1).times small_obj.download_file(path, version_id: version_id) end @@ -185,11 +185,11 @@ module S3 let(:chunk_size) { 5 * one_meg } before :each do - allow(client).to receive(:head_object).with( + allow(client).to receive(:head_object).with({ bucket: 'bucket', key: 'boundary', part_number: 1 - ).and_return( + }).and_return( client.stub_data( :head_object, content_length: file_size @@ -207,21 +207,21 @@ module S3 end it 'downloads the file with default chunk size' do - expect(client).to receive(:head_object).with( + expect(client).to receive(:head_object).with({ bucket: 'bucket', key: 'boundary', part_number: 1 - ).exactly(1).times + }).exactly(1).times boundary_obj.download_file(path) end it 'downloads the file with provided chunk size' do - expect(client).to receive(:head_object).with( + expect(client).to receive(:head_object).with({ bucket: 'bucket', key: 'boundary', part_number: 1 - ).exactly(1).times + }).exactly(1).times boundary_obj.download_file(path, chunk_size: chunk_size) end diff --git a/gems/aws-sdk-s3/spec/object/presigned_url_spec.rb b/gems/aws-sdk-s3/spec/object/presigned_url_spec.rb index 6562a7d1f26..27eab0f40e5 100644 --- a/gems/aws-sdk-s3/spec/object/presigned_url_spec.rb +++ b/gems/aws-sdk-s3/spec/object/presigned_url_spec.rb @@ -51,8 +51,7 @@ module S3 expect(presigner).to receive(:presigned_url).with( expected_method, - bucket: bucket_name, - key: key + { bucket: bucket_name, key: key } ) obj.presigned_url(method) @@ -140,8 +139,7 @@ module S3 expect(presigner).to receive(:presigned_request).with( expected_method, - bucket: bucket_name, - key: key + { bucket: bucket_name, key: key } ) obj.presigned_request(method) diff --git a/gems/aws-sdk-s3/spec/object/upload_file_spec.rb b/gems/aws-sdk-s3/spec/object/upload_file_spec.rb index a76b6df8d0b..8c1ca8153d8 100644 --- a/gems/aws-sdk-s3/spec/object/upload_file_spec.rb +++ b/gems/aws-sdk-s3/spec/object/upload_file_spec.rb @@ -53,11 +53,11 @@ module S3 it 'uploads objects with custom options without mutating them' do options = {}.freeze - expect(client).to receive(:put_object).with( + expect(client).to receive(:put_object).with({ bucket: 'bucket', key: 'key', body: one_meg_file - ) + }) object.upload_file(one_meg_file, options) end @@ -70,21 +70,21 @@ module S3 context 'small objects' do it 'uploads small objects using Client#put_object' do - expect(client).to receive(:put_object).with( + expect(client).to receive(:put_object).with({ bucket: 'bucket', key: 'key', body: ten_meg_file - ) + }) object.upload_file(ten_meg_file) end it 'reports progress for small objects' do - expect(client).to receive(:put_object).with( + expect(client).to receive(:put_object).with({ bucket: 'bucket', key: 'key', body: ten_meg_file, on_chunk_sent: instance_of(Proc) - ) do |args| + }) do |args| args[:on_chunk_sent].call(ten_meg_file, ten_meg_file.size, ten_meg_file.size) end callback = proc do |bytes, totals| @@ -95,11 +95,11 @@ module S3 end it 'accepts an alternative multipart file threshold' do - expect(client).to receive(:put_object).with( + expect(client).to receive(:put_object).with({ bucket: 'bucket', key: 'key', body: one_hundred_seventeen_meg_file - ) + }) object.upload_file( one_hundred_seventeen_meg_file, multipart_threshold: 200 * one_meg @@ -110,20 +110,20 @@ module S3 file = double('file') expect(File).to receive(:open) .with(ten_meg_file.path, 'rb').and_yield(file) - expect(client).to receive(:put_object).with( + expect(client).to receive(:put_object).with({ bucket: 'bucket', key: 'key', body: file - ) + }) object.upload_file(ten_meg_file.path) end it 'does not fail when given :thread_count' do - expect(client).to receive(:put_object).with( + expect(client).to receive(:put_object).with({ bucket: 'bucket', key: 'key', body: ten_meg_file - ) + }) object.upload_file(ten_meg_file, thread_count: 1) end end From a36cc3d47e1855e712c725882efd34a232202365 Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Mon, 14 Feb 2022 14:36:29 -0800 Subject: [PATCH 8/9] Assortment of smaller fixes --- .../spec/cognito_identity_credentials_spec.rb | 6 ++--- .../spec/aws/assume_role_credentials_spec.rb | 6 ++--- ...sume_role_web_identity_credentials_spec.rb | 24 +++++++++---------- .../spec/aws/sso_credentials_spec.rb | 2 +- .../spec/seahorse/client/base_spec.rb | 2 +- gems/aws-sdk-s3/spec/bucket/delete_spec.rb | 16 ++++++------- gems/aws-sdk-s3/spec/multipart_upload_spec.rb | 8 +++---- gems/aws-sdk-s3/spec/object/move_to_spec.rb | 8 +++---- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/gems/aws-sdk-cognitoidentity/spec/cognito_identity_credentials_spec.rb b/gems/aws-sdk-cognitoidentity/spec/cognito_identity_credentials_spec.rb index 9178c0d5aa5..40f1d00aab2 100644 --- a/gems/aws-sdk-cognitoidentity/spec/cognito_identity_credentials_spec.rb +++ b/gems/aws-sdk-cognitoidentity/spec/cognito_identity_credentials_spec.rb @@ -36,7 +36,7 @@ module CognitoIdentity it 'constructs a client with passed arguments when not given' do expect(CognitoIdentity::Client).to receive(:new) - .with(region: 'us-east-1', credentials: false) + .with({region: 'us-east-1', credentials: false}) .and_return(client) creds = CognitoIdentityCredentials.new( @@ -77,7 +77,7 @@ module CognitoIdentity expect(client).to receive(:get_id) .with(identity_pool_id: identity_pool_id) .and_return(double("getid", identity_id: identity_id)) - + creds = CognitoIdentityCredentials.new( client: client, identity_pool_id: identity_pool_id ) @@ -112,7 +112,7 @@ module CognitoIdentity before_refresh_called = true expect(cred_provider).to be_instance_of(CognitoIdentityCredentials) end - + CognitoIdentityCredentials.new( client: client, identity_id: identity_id, diff --git a/gems/aws-sdk-core/spec/aws/assume_role_credentials_spec.rb b/gems/aws-sdk-core/spec/aws/assume_role_credentials_spec.rb index 0aec4937df0..c46d655c868 100644 --- a/gems/aws-sdk-core/spec/aws/assume_role_credentials_spec.rb +++ b/gems/aws-sdk-core/spec/aws/assume_role_credentials_spec.rb @@ -53,7 +53,7 @@ module Aws it 'accepts client options' do client = STS::Client.new(stub_responses: true) expect(STS::Client).to receive(:new). - with(region: 'region-name'). + with({region: 'region-name'}). and_return(client) creds = AssumeRoleCredentials.new( region: 'region-name', @@ -64,13 +64,13 @@ module Aws end it 'assumes a role using the client' do - expect(client).to receive(:assume_role).with( + expect(client).to receive(:assume_role).with({ role_arn: 'arn', role_session_name: 'session', policy: 'policy', duration_seconds: 100, external_id: 'id' - ).and_return(resp) + }).and_return(resp) AssumeRoleCredentials.new( client: client, role_arn: 'arn', diff --git a/gems/aws-sdk-core/spec/aws/assume_role_web_identity_credentials_spec.rb b/gems/aws-sdk-core/spec/aws/assume_role_web_identity_credentials_spec.rb index a17a455d0a4..2292546d343 100644 --- a/gems/aws-sdk-core/spec/aws/assume_role_web_identity_credentials_spec.rb +++ b/gems/aws-sdk-core/spec/aws/assume_role_web_identity_credentials_spec.rb @@ -60,11 +60,11 @@ module Aws end it 'auto populates :session_name when not provided' do - expect(client).to receive(:assume_role_with_web_identity).with( + expect(client).to receive(:assume_role_with_web_identity).with({ role_arn: 'arn', - web_identity_token: '', + web_identity_token: '', role_session_name: generate_name - ) + }) AssumeRoleWebIdentityCredentials.new( role_arn: 'arn', web_identity_token_file: token_file_path, @@ -74,24 +74,24 @@ module Aws it 'populates :web_identity_token from file when valid' do expect { AssumeRoleWebIdentityCredentials.new( - role_arn: 'arn') + role_arn: 'arn') }.to raise_error(Aws::Errors::MissingWebIdentityTokenFile) expect { AssumeRoleWebIdentityCredentials.new( role_arn: 'arn', web_identity_token_file: '/not/exist/file/foo', - ) + ) }.to raise_error(Aws::Errors::MissingWebIdentityTokenFile) token_file.write('token') token_file.flush token_file.close - expect(client).to receive(:assume_role_with_web_identity).with( + expect(client).to receive(:assume_role_with_web_identity).with({ role_arn: 'arn', web_identity_token: 'token', role_session_name: "session-name" - ) + }) AssumeRoleWebIdentityCredentials.new( role_arn: 'arn', web_identity_token_file: token_file_path, @@ -112,7 +112,7 @@ module Aws expected_client = STS::Client.new( credentials: false, stub_responses: true) expect(STS::Client).to receive(:new). - with(region: 'region-name', credentials: false). + with({region: 'region-name', credentials: false}). and_return(expected_client) creds = AssumeRoleWebIdentityCredentials.new( region: 'region-name', @@ -123,13 +123,13 @@ module Aws end it 'assumes role with web identity using the client' do - expect(client).to receive(:assume_role_with_web_identity).with( + expect(client).to receive(:assume_role_with_web_identity).with({ role_arn: 'arn', - web_identity_token: '', + web_identity_token: '', role_session_name: "session-name", provider_id: "urlType", policy: "sessionPolicyDocumentType" - ) + }) AssumeRoleWebIdentityCredentials.new( role_arn: 'arn', web_identity_token_file: token_file_path, @@ -143,7 +143,7 @@ module Aws c = AssumeRoleWebIdentityCredentials.new( role_arn: 'arn', web_identity_token_file: token_file_path, - ) + ) expect(c).to be_set expect(c.credentials.access_key_id).to eq('akid') expect(c.credentials.secret_access_key).to eq('secret') diff --git a/gems/aws-sdk-core/spec/aws/sso_credentials_spec.rb b/gems/aws-sdk-core/spec/aws/sso_credentials_spec.rb index e9d5771d7fb..8f80c7939e8 100644 --- a/gems/aws-sdk-core/spec/aws/sso_credentials_spec.rb +++ b/gems/aws-sdk-core/spec/aws/sso_credentials_spec.rb @@ -66,7 +66,7 @@ def mock_token_file(start_url, cached_token) it 'constructs an client with passed arguments when not given' do expect(SSO::Client).to receive(:new) - .with(region: sso_region, credentials: nil) + .with({region: sso_region, credentials: nil}) .and_return(client) mock_token_file(sso_start_url, cached_token) diff --git a/gems/aws-sdk-core/spec/seahorse/client/base_spec.rb b/gems/aws-sdk-core/spec/seahorse/client/base_spec.rb index 12bb6a79b58..88b7b4c6b28 100644 --- a/gems/aws-sdk-core/spec/seahorse/client/base_spec.rb +++ b/gems/aws-sdk-core/spec/seahorse/client/base_spec.rb @@ -143,7 +143,7 @@ module Client it 'builds and sends a request when it receives a request method' do expect(client).to receive(:build_request). - with(:operation_name, foo:'bar'). + with(:operation_name, {foo:'bar'}). and_return(request) expect(request).to receive(:send_request) client.operation_name(foo:'bar') diff --git a/gems/aws-sdk-s3/spec/bucket/delete_spec.rb b/gems/aws-sdk-s3/spec/bucket/delete_spec.rb index e3fc5a1be12..a99ea30b2f9 100644 --- a/gems/aws-sdk-s3/spec/bucket/delete_spec.rb +++ b/gems/aws-sdk-s3/spec/bucket/delete_spec.rb @@ -53,7 +53,7 @@ module S3 .and_call_original expect(client).to receive(:delete_bucket) - .with(bucket: 'bucket-name') + .with({bucket: 'bucket-name'}) .and_call_original bucket.delete! @@ -79,19 +79,19 @@ module S3 .exactly(3).times expect(client).to receive(:delete_bucket) - .with(bucket: 'bucket-name') + .with({bucket: 'bucket-name'}) .and_raise(bucket_not_empty_exception).ordered expect(Kernel).to receive(:sleep).with(default_initial_wait).ordered expect(client).to receive(:delete_bucket) - .with(bucket: 'bucket-name') + .with({bucket: 'bucket-name'}) .and_raise(bucket_not_empty_exception).ordered expect(Kernel).to receive(:sleep).with(second_attempt_wait).ordered expect(client).to receive(:delete_bucket) - .with(bucket: 'bucket-name').ordered + .with({bucket: 'bucket-name'}).ordered .and_call_original bucket.delete! @@ -111,19 +111,19 @@ module S3 .exactly(3).times expect(client).to receive(:delete_bucket) - .with(bucket: 'bucket-name') + .with({bucket: 'bucket-name'}) .and_raise(bucket_not_empty_exception).ordered expect(Kernel).to receive(:sleep).with(initial_wait).ordered expect(client).to receive(:delete_bucket) - .with(bucket: 'bucket-name') + .with({bucket: 'bucket-name'}) .and_raise(bucket_not_empty_exception).ordered expect(Kernel).to receive(:sleep).with(initial_wait**2).ordered expect(client).to receive(:delete_bucket) - .with(bucket: 'bucket-name').ordered + .with({bucket: 'bucket-name'}).ordered .and_call_original bucket.delete!(initial_wait: initial_wait) @@ -144,7 +144,7 @@ module S3 .and_call_original expect(client).to receive(:delete_bucket) - .with(bucket: 'bucket-name') + .with({bucket: 'bucket-name'}) .and_raise(bucket_not_empty_exception) expect do diff --git a/gems/aws-sdk-s3/spec/multipart_upload_spec.rb b/gems/aws-sdk-s3/spec/multipart_upload_spec.rb index da6ba470a6d..d564ccac94a 100644 --- a/gems/aws-sdk-s3/spec/multipart_upload_spec.rb +++ b/gems/aws-sdk-s3/spec/multipart_upload_spec.rb @@ -13,7 +13,7 @@ module S3 end it 'calls complete with the given part list' do - expect(client).to receive(:complete_multipart_upload).with( + expect(client).to receive(:complete_multipart_upload).with({ bucket: 'bucket', key: 'key', upload_id: 'id', @@ -24,7 +24,7 @@ module S3 { part_number: 3, etag: 'etag-3' } ] } - ) + }) obj = upload.complete( multipart_upload: { @@ -52,7 +52,7 @@ module S3 ] ) - expect(client).to receive(:complete_multipart_upload).with( + expect(client).to receive(:complete_multipart_upload).with({ bucket: 'bucket', key: 'key', upload_id: 'id', @@ -63,7 +63,7 @@ module S3 { part_number: 3, etag: 'etag-3' } ] } - ).and_call_original + }).and_call_original obj = upload.complete(compute_parts: true) expect(obj).to be_kind_of(S3::Object) diff --git a/gems/aws-sdk-s3/spec/object/move_to_spec.rb b/gems/aws-sdk-s3/spec/object/move_to_spec.rb index 3beb0b6cb0c..d34536ca7ca 100644 --- a/gems/aws-sdk-s3/spec/object/move_to_spec.rb +++ b/gems/aws-sdk-s3/spec/object/move_to_spec.rb @@ -8,16 +8,16 @@ module S3 describe '#move_to' do it 'copies and then deletes the object' do client = Client.new(stub_responses: true) - expect(client).to receive(:copy_object).with( + expect(client).to receive(:copy_object).with({ bucket: 'target-bucket', key: 'target-key', copy_source: 'source-bucket/source-key' - ).and_call_original + }).and_call_original - expect(client).to receive(:delete_object).with( + expect(client).to receive(:delete_object).with({ bucket: 'source-bucket', key: 'source-key' - ).and_call_original + }).and_call_original obj = S3::Object.new('source-bucket', 'source-key', client: client) obj.move_to('target-bucket/target-key') From 6af6b609dc6d13036a81212ad7bbd91b290374f4 Mon Sep 17 00:00:00 2001 From: Matt Muller Date: Mon, 14 Feb 2022 14:40:10 -0800 Subject: [PATCH 9/9] Fix everything I think --- .../spec/object/upload_stream_spec.rb | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/gems/aws-sdk-s3/spec/object/upload_stream_spec.rb b/gems/aws-sdk-s3/spec/object/upload_stream_spec.rb index edfa1b8a182..cf11f966cee 100644 --- a/gems/aws-sdk-s3/spec/object/upload_stream_spec.rb +++ b/gems/aws-sdk-s3/spec/object/upload_stream_spec.rb @@ -71,34 +71,34 @@ module S3 it 'uploads the correct parts' do client.stub_responses(:create_multipart_upload, upload_id: 'id') client.stub_responses(:complete_multipart_upload) - expect(client).to receive(:upload_part).with( + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(StringIO), part_number: 1 - ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + }).once.and_return(double(:upload_part, etag: 'etag')) + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(StringIO), part_number: 2 - ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + }).once.and_return(double(:upload_part, etag: 'etag')) + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(StringIO), part_number: 3 - ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + }).once.and_return(double(:upload_part, etag: 'etag')) + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(StringIO), part_number: 4 - ).once.and_return(double(:upload_part, etag: 'etag')) + }).once.and_return(double(:upload_part, etag: 'etag')) object.upload_stream do |write_stream| write_stream << seventeen_mb end @@ -107,34 +107,34 @@ module S3 it 'uploads the correct parts when input is chunked' do client.stub_responses(:create_multipart_upload, upload_id: 'id') client.stub_responses(:complete_multipart_upload) - expect(client).to receive(:upload_part).with( + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(StringIO), part_number: 1 - ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + }).once.and_return(double(:upload_part, etag: 'etag')) + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(StringIO), part_number: 2 - ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + }).once.and_return(double(:upload_part, etag: 'etag')) + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(StringIO), part_number: 3 - ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + }).once.and_return(double(:upload_part, etag: 'etag')) + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(StringIO), part_number: 4 - ).once.and_return(double(:upload_part, etag: 'etag')) + }).once.and_return(double(:upload_part, etag: 'etag')) object.upload_stream do |write_stream| 17.times { write_stream << one_mb } end @@ -143,27 +143,27 @@ module S3 it 'uploads correct parts when chunked with custom part_size' do client.stub_responses(:create_multipart_upload, upload_id: 'id') client.stub_responses(:complete_multipart_upload) - expect(client).to receive(:upload_part).with( + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(StringIO), part_number: 1 - ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + }).once.and_return(double(:upload_part, etag: 'etag')) + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(StringIO), part_number: 2 - ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + }).once.and_return(double(:upload_part, etag: 'etag')) + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(StringIO), part_number: 3 - ).once.and_return(double(:upload_part, etag: 'etag')) + }).once.and_return(double(:upload_part, etag: 'etag')) object.upload_stream(part_size: 7 * 1024 * 1024) do |write_stream| 17.times { write_stream << one_mb } end @@ -302,13 +302,13 @@ module S3 it 'uploads the correct parts' do client.stub_responses(:create_multipart_upload, upload_id: 'id') client.stub_responses(:complete_multipart_upload) - expect(client).to receive(:upload_part).with( + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(Tempfile), part_number: 1 - ).once.and_return(double(:upload_part, etag: 'etag')) + }).once.and_return(double(:upload_part, etag: 'etag')) expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', @@ -338,34 +338,34 @@ module S3 it 'uploads the correct parts when input is chunked' do client.stub_responses(:create_multipart_upload, upload_id: 'id') client.stub_responses(:complete_multipart_upload) - expect(client).to receive(:upload_part).with( + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(Tempfile), part_number: 1 - ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + }).once.and_return(double(:upload_part, etag: 'etag')) + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(Tempfile), part_number: 2 - ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + }).once.and_return(double(:upload_part, etag: 'etag')) + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(Tempfile), part_number: 3 - ).once.and_return(double(:upload_part, etag: 'etag')) - expect(client).to receive(:upload_part).with( + }).once.and_return(double(:upload_part, etag: 'etag')) + expect(client).to receive(:upload_part).with({ bucket: 'bucket', key: 'key', upload_id: 'id', body: instance_of(Tempfile), part_number: 4 - ).once.and_return(double(:upload_part, etag: 'etag')) + }).once.and_return(double(:upload_part, etag: 'etag')) object.upload_stream(tempfile: true) do |write_stream| 17.times { write_stream << one_mb } end