Replace mocha by rspec-mocks

puppetlabs_spec_helper recommends rspec-mocks instead of mocha[1] and
it uses rspec-mocks by default instead of mocha since v 5.0.0[2]

This is the prep work to adapt to that migration.

[1] https://github.com/puppetlabs/puppetlabs_spec_helper/#mock_with
[2] 493f0cbc1c

Closes-Bug: #2004135
Change-Id: Iff0c788f58592a24dcd6ad4cca7e46468fa82d00
This commit is contained in:
Takashi Kajinami 2023-01-30 11:32:17 +09:00
parent 66ae8a1b35
commit 57b862412e
3 changed files with 12 additions and 10 deletions

View File

@ -13,6 +13,8 @@ RSpec.configure do |c|
c.module_path = File.join(fixture_path, 'modules')
c.manifest_dir = File.join(fixture_path, 'manifests')
c.mock_with :rspec
end
at_exit { RSpec::Puppet::Coverage.report! }

View File

@ -35,9 +35,9 @@ describe provider_class do
describe "self.instances" do
it 'lists datastores' do
provider_class.expects(:openstack)
expect(provider_class).to receive(:openstack)
.with('datastore', 'list', '--quiet', '--format', 'csv', [])
.returns('"ID","Name"
.and_return('"ID","Name"
"1275b24c-73af-4c51-98ec-c9938a94a153","store1"
"18088802-efe2-42f8-ac85-ecfddd37d24e","store2"
')
@ -52,13 +52,13 @@ describe provider_class do
describe '#create' do
it 'creates datastore' do
provider.expects(:trove_manage)
expect(provider).to receive(:trove_manage)
.with(['trove-manage', 'datastore_update', datastore_name, "''"])
.returns(0)
.and_return(0)
provider.expects(:trove_manage)
expect(provider).to receive(:trove_manage)
.with(['trove-manage', 'datastore_update', datastore_name, "0.1"])
.returns(0)
.and_return(0)
provider.create
end

View File

@ -49,10 +49,10 @@ describe provider_class do
describe '#create' do
it 'should call trove-manage' do
provider.expects(:trove_manage).with(
expect(provider). to receive(:trove_manage).with(
['trove-manage', 'datastore_version_update', datastore_name,
datastore_version, 'mysql', '1234', 'mysql', '1']
).returns(0)
).and_return(0)
provider.create
end
@ -60,10 +60,10 @@ describe provider_class do
describe '#exists' do
it 'should list datastore versions' do
provider_class.expects(:openstack)
expect(provider_class).to receive(:openstack)
.with('datastore version', 'list', '--quiet', '--format', 'csv',
datastore_name)
.returns('"ID","Name","Version"
.and_return('"ID","Name","Version"
"9c4d3fb1-644c-4543-9c37-49b3a801b66c","5.7.29","5.7.29"
"406b75fb-0727-4923-a702-d677e3fd84ab","5.7.30","5.7.30"
')