Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ruby3 specs for rspec-mocks 3.10.3 change #2652

Merged
merged 10 commits into from
Feb 14, 2022
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ group :test do

gem 'multipart-post'
gem 'rspec'
gem 'rspec-mocks', '<= 3.10.2'
end

group :build do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -49,15 +49,15 @@

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)
end

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')
Expand Down Expand Up @@ -243,15 +243,15 @@
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)
end

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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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' },
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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: [
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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:[
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions gems/aws-sdk-core/spec/aws/assume_role_credentials_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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',
Expand All @@ -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,
Expand All @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion gems/aws-sdk-core/spec/aws/sso_credentials_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gems/aws-sdk-core/spec/seahorse/client/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Loading