From 8b24506c2f605bb7e0926f1e5e197a006a5de708 Mon Sep 17 00:00:00 2001 From: Steven Pritchard Date: Tue, 18 Jun 2024 15:44:26 -0500 Subject: [PATCH 1/2] Switch from mocha to rspec mocks --- spec/classes/server/global_spec.rb | 2 +- spec/spec_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/classes/server/global_spec.rb b/spec/classes/server/global_spec.rb index 77f5f2f..2d461b6 100644 --- a/spec/classes/server/global_spec.rb +++ b/spec/classes/server/global_spec.rb @@ -3,7 +3,7 @@ describe 'rsync::server::global' do before(:each) do Puppet::Parser::Functions.newfunction('assert_private') do |f| - f.stubs(:call).returns(true) + allow(f).to receive(:call).and_return(true) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6a687f0..56770df 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -94,7 +94,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) From 278e676fc855917d977b75cd0bb238076808db09 Mon Sep 17 00:00:00 2001 From: Steven Pritchard Date: Thu, 20 Jun 2024 11:42:37 -0500 Subject: [PATCH 2/2] Properly mask assert_private() --- spec/classes/server/global_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/classes/server/global_spec.rb b/spec/classes/server/global_spec.rb index 2d461b6..37cbaa2 100644 --- a/spec/classes/server/global_spec.rb +++ b/spec/classes/server/global_spec.rb @@ -2,9 +2,8 @@ describe 'rsync::server::global' do before(:each) do - Puppet::Parser::Functions.newfunction('assert_private') do |f| - allow(f).to receive(:call).and_return(true) - end + # Mask 'assert_private' for testing + Puppet::Parser::Functions.newfunction(:assert_private, :type => :rvalue) { |args| } end context 'supported operating systems' do