Update test syntax to remove stubs (#1138)

Use of stubs are deprecated, switch to the newer expect/allow syntax.
This commit is contained in:
Darragh Bailey
2020-08-16 16:06:05 +01:00
committed by GitHub
parent dda5d4e1c4
commit 74c381a30d
4 changed files with 7 additions and 7 deletions

View File

@@ -25,6 +25,6 @@ shared_context 'libvirt' do
# return some information for domain when needed # return some information for domain when needed
allow(domain).to receive(:mac).and_return('9C:D5:53:F1:5A:E7') allow(domain).to receive(:mac).and_return('9C:D5:53:F1:5A:E7')
machine.stub(id: id) allow(machine).to receive(:id).and_return(id)
end end
end end

View File

@@ -28,7 +28,7 @@ shared_context 'unit' do
let(:plugin) { register_plugin } let(:plugin) { register_plugin }
before (:each) do before (:each) do
machine.stub(guest: guest) allow(machine).to receive(:guest).and_return(guest)
machine.stub(communicator: communicator) allow(machine).to receive(:communicator).and_return(communicator)
end end
end end

View File

@@ -33,7 +33,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::DestroyDomain do
before do before do
allow(libvirt_domain).to receive(:list_snapshots).and_return([]) allow(libvirt_domain).to receive(:list_snapshots).and_return([])
allow(libvirt_domain).to receive(:has_managed_save?).and_return(nil) allow(libvirt_domain).to receive(:has_managed_save?).and_return(nil)
root_disk.stub(name: 'test.img') allow(root_disk).to receive(:name).and_return('test.img')
end end
context 'when only has root disk' do context 'when only has root disk' do
@@ -57,7 +57,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::DestroyDomain do
let(:extra_disk) { double('libvirt_extra_disk') } let(:extra_disk) { double('libvirt_extra_disk') }
before do before do
extra_disk.stub(name: 'test-vdb.qcow2') allow(extra_disk).to receive(:name).and_return('test-vdb.qcow2')
end end
it 'destroys disks individually' do it 'destroys disks individually' do

View File

@@ -10,12 +10,12 @@ describe VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain do
dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env) dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
first = dmn.build_domain_name(@env) first = dmn.build_domain_name(@env)
second = dmn.build_domain_name(@env) second = dmn.build_domain_name(@env)
first.should_not eq(second) expect(first).to_not eq(second)
end end
it 'builds simple domain name' do it 'builds simple domain name' do
@env.default_prefix = 'pre_' @env.default_prefix = 'pre_'
dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env) dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
dmn.build_domain_name(@env).should eq('pre_') expect(dmn.build_domain_name(@env)).to eq('pre_')
end end
end end