From aa393f881cdc016d7bc9f6ae890c3afbe22668da Mon Sep 17 00:00:00 2001 From: Steven Pritchard Date: Tue, 18 Jun 2024 15:35:39 -0500 Subject: [PATCH] Switch from mocha to rspec mocks --- spec/spec_helper.rb | 2 +- .../provider/incron_system_table/manage_spec.rb | 14 +++++++------- spec/unit/puppet/type/incron_system_table_spec.rb | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 69a57c8..2b7046e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -91,7 +91,7 @@ def set_hieradata(hieradata) } c.mock_framework = :rspec - c.mock_with :mocha + c.mock_with :rspec c.module_path = File.join(fixture_path, 'modules') c.manifest_dir = File.join(fixture_path, 'manifests') if c.respond_to?(:manifest_dir) diff --git a/spec/unit/puppet/provider/incron_system_table/manage_spec.rb b/spec/unit/puppet/provider/incron_system_table/manage_spec.rb index 009ac2a..1bc816f 100755 --- a/spec/unit/puppet/provider/incron_system_table/manage_spec.rb +++ b/spec/unit/puppet/provider/incron_system_table/manage_spec.rb @@ -14,11 +14,11 @@ FileUtils.mkdir_p(File.join(@tmpdir, 'that', 'is', '2', 'test')) FileUtils.mkdir_p(File.join(@tmpdir, 'other', 'is', '3', 'test')) - File.stubs(:read).with('/etc/incron.conf'). + allow(File).to receive(:read).with('/etc/incron.conf'). returns("system_table_dir = #{@tmpdir}") # Must be mocked, but does't really matter what it returns in these tests - Facter.stubs(:value).with(:incrond_version) + allow(Facter).to receive(:value).with(:incrond_version) end after(:each) do @@ -51,8 +51,8 @@ context 'does exist' do context 'does match' do it do - File.stubs(:readable?).with(File.join(@tmpdir, resource_name)).returns(true) - File.stubs(:read).with(File.join(@tmpdir, resource_name)). + allow(File).to receive(:readable?).with(File.join(@tmpdir, resource_name)).and_return(true) + allow(File).to receive(:read).with(File.join(@tmpdir, resource_name)). returns("#{path} #{mask} #{command}") expect(provider.exists?).to be true @@ -61,7 +61,7 @@ context 'is not readable' do it do - File.stubs(:readable?).with(File.join(@tmpdir, resource_name)).returns(false) + allow(File).to receive(:readable?).with(File.join(@tmpdir, resource_name)).and_return(false) expect(provider.exists?).to be false end @@ -69,8 +69,8 @@ context 'does not match' do it do - File.stubs(:readable?).with(File.join(@tmpdir, resource_name)).returns(true) - File.stubs(:read).with(File.join(@tmpdir, resource_name)). + allow(File).to receive(:readable?).with(File.join(@tmpdir, resource_name)).and_return(true) + allow(File).to receive(:read).with(File.join(@tmpdir, resource_name)). returns("#{path} #{mask} #{command} and stuff") expect(provider.exists?).to be false diff --git a/spec/unit/puppet/type/incron_system_table_spec.rb b/spec/unit/puppet/type/incron_system_table_spec.rb index 834148d..f03b315 100644 --- a/spec/unit/puppet/type/incron_system_table_spec.rb +++ b/spec/unit/puppet/type/incron_system_table_spec.rb @@ -79,7 +79,7 @@ context 'on a system with no incrond_version fact' do it 'should strip out the new parameters' do - Facter.stubs(:value).with(:incrond_version).returns(nil) + allow(Facter).to receive(:value).with(:incrond_version).and_return(nil) resource = incron_system_table_type.new( :name => name, @@ -94,7 +94,7 @@ context 'on a system with an older version of incrond' do it 'should strip out the new parameters' do - Facter.stubs(:value).with(:incrond_version).returns('0.5.10') + allow(Facter).to receive(:value).with(:incrond_version).and_return('0.5.10') resource = incron_system_table_type.new( :name => name, @@ -109,7 +109,7 @@ context 'on a system with 0.5.12' do it 'should retain the new parameters' do - Facter.stubs(:value).with(:incrond_version).returns('0.5.12') + allow(Facter).to receive(:value).with(:incrond_version).and_return('0.5.12') resource = incron_system_table_type.new( :name => name, @@ -124,7 +124,7 @@ context 'on a system with incrond newer than 0.5.12' do it 'should retain the new parameters' do - Facter.stubs(:value).with(:incrond_version).returns('0.5.13') + allow(Facter).to receive(:value).with(:incrond_version).and_return('0.5.13') resource = incron_system_table_type.new( :name => name,