Skip to content

Commit 56a4b81

Browse files
committed
feat: add .ps_manager mocks for non-Windows (pwsh_path and pwsh_args)
1 parent 03ba8c7 commit 56a4b81

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

spec/unit/puppet/provider/dsc_base_provider/dsc_base_provider_spec.rb

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,21 +2110,44 @@
21102110
end
21112111

21122112
describe '.ps_manager' do
2113-
before do
2114-
allow(Pwsh::Manager).to receive(:powershell_path).and_return('pwsh')
2115-
allow(Pwsh::Manager).to receive(:powershell_args).and_return('args')
2116-
end
2113+
describe '.ps_manager on non-Windows' do
2114+
before do
2115+
allow(Pwsh::Util).to receive(:on_windows?).and_return(false)
2116+
allow(Pwsh::Manager).to receive(:pwsh_path).and_return('pwsh')
2117+
allow(Pwsh::Manager).to receive(:pwsh_args).and_return('args')
2118+
end
21172119

2118-
it 'Initializes an instance of the Pwsh::Manager' do
2119-
expect(Puppet::Util::Log).to receive(:level).and_return(:normal)
2120-
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: false)
2121-
expect { provider.ps_manager }.not_to raise_error
2120+
it 'Initializes an instance of the Pwsh::Manager' do
2121+
expect(Puppet::Util::Log).to receive(:level).and_return(:normal)
2122+
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: false)
2123+
expect { provider.ps_manager }.not_to raise_error
2124+
end
2125+
2126+
it 'passes debug as true if Puppet::Util::Log.level is debug' do
2127+
expect(Puppet::Util::Log).to receive(:level).and_return(:debug)
2128+
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: true)
2129+
expect { provider.ps_manager }.not_to raise_error
2130+
end
21222131
end
21232132

2124-
it 'passes debug as true if Puppet::Util::Log.level is debug' do
2125-
expect(Puppet::Util::Log).to receive(:level).and_return(:debug)
2126-
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: true)
2127-
expect { provider.ps_manager }.not_to raise_error
2133+
describe '.ps_manager on Windows' do
2134+
before do
2135+
allow(Pwsh::Util).to receive(:on_windows?).and_return(true)
2136+
allow(Pwsh::Manager).to receive(:powershell_path).and_return('pwsh')
2137+
allow(Pwsh::Manager).to receive(:powershell_args).and_return('args')
2138+
end
2139+
2140+
it 'Initializes an instance of the Pwsh::Manager' do
2141+
expect(Puppet::Util::Log).to receive(:level).and_return(:normal)
2142+
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: false)
2143+
expect { provider.ps_manager }.not_to raise_error
2144+
end
2145+
2146+
it 'passes debug as true if Puppet::Util::Log.level is debug' do
2147+
expect(Puppet::Util::Log).to receive(:level).and_return(:debug)
2148+
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: true)
2149+
expect { provider.ps_manager }.not_to raise_error
2150+
end
21282151
end
21292152
end
21302153
end

0 commit comments

Comments
 (0)