Skip to content

Commit

Permalink
feat: add .ps_manager mocks for non-Windows (pwsh_path and pwsh_args)
Browse files Browse the repository at this point in the history
  • Loading branch information
chambersmp committed Apr 15, 2024
1 parent 03ba8c7 commit 4db604a
Showing 1 changed file with 36 additions and 12 deletions.
Expand Up @@ -2110,21 +2110,45 @@
end

describe '.ps_manager' do
before do
allow(Pwsh::Manager).to receive(:powershell_path).and_return('pwsh')
allow(Pwsh::Manager).to receive(:powershell_args).and_return('args')
end
describe '.ps_manager on non-Windows' do
before do

Check failure on line 2115 in spec/unit/puppet/provider/dsc_base_provider/dsc_base_provider_spec.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 3.2 | puppet ~> 8.0) / spec

Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.

Check failure on line 2115 in spec/unit/puppet/provider/dsc_base_provider/dsc_base_provider_spec.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 2.7 | puppet ~> 7.0) / spec

Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
allow(Pwsh::Util).to receive(:on_windows?).and_return(false)
allow(Pwsh::Manager).to receive(:pwsh_path).and_return('pwsh')
allow(Pwsh::Manager).to receive(:pwsh_args).and_return('args')
end

it 'Initializes an instance of the Pwsh::Manager' do
expect(Puppet::Util::Log).to receive(:level).and_return(:normal)
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: false)
expect { provider.ps_manager }.not_to raise_error
end

it 'Initializes an instance of the Pwsh::Manager' do
expect(Puppet::Util::Log).to receive(:level).and_return(:normal)
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: false)
expect { provider.ps_manager }.not_to raise_error
it 'passes debug as true if Puppet::Util::Log.level is debug' do
expect(Puppet::Util::Log).to receive(:level).and_return(:debug)
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: true)
expect { provider.ps_manager }.not_to raise_error
end
end

it 'passes debug as true if Puppet::Util::Log.level is debug' do
expect(Puppet::Util::Log).to receive(:level).and_return(:debug)
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: true)
expect { provider.ps_manager }.not_to raise_error
describe '.ps_manager on Windows' do
before do

Check failure on line 2136 in spec/unit/puppet/provider/dsc_base_provider/dsc_base_provider_spec.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 3.2 | puppet ~> 8.0) / spec

Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.

Check failure on line 2136 in spec/unit/puppet/provider/dsc_base_provider/dsc_base_provider_spec.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 2.7 | puppet ~> 7.0) / spec

Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
allow(Pwsh::Util).to receive(:on_windows?).and_return(true)
allow(Pwsh::Manager).to receive(:powershell_path).and_return('pwsh')
allow(Pwsh::Manager).to receive(:powershell_args).and_return('args')
end

Check failure on line 2140 in spec/unit/puppet/provider/dsc_base_provider/dsc_base_provider_spec.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 3.2 | puppet ~> 8.0) / spec

RSpec/EmptyLineAfterHook: Add an empty line after `before`.

Check failure on line 2140 in spec/unit/puppet/provider/dsc_base_provider/dsc_base_provider_spec.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 2.7 | puppet ~> 7.0) / spec

RSpec/EmptyLineAfterHook: Add an empty line after `before`.
it 'Initializes an instance of the Pwsh::Manager' do
expect(Puppet::Util::Log).to receive(:level).and_return(:normal)
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: false)
expect { provider.ps_manager }.not_to raise_error
end

it 'passes debug as true if Puppet::Util::Log.level is debug' do
expect(Puppet::Util::Log).to receive(:level).and_return(:debug)
expect(Pwsh::Manager).to receive(:instance).with('pwsh', 'args', debug: true)
expect { provider.ps_manager }.not_to raise_error
end
end
end
end

0 comments on commit 4db604a

Please sign in to comment.