Skip to content

Commit

Permalink
Feat: add .ps_manager mocks to use pwsh_path and pwsh_args on non-Win…
Browse files Browse the repository at this point in the history
…dows
  • Loading branch information
chambersmp committed Apr 15, 2024
1 parent 03ba8c7 commit 63b9887
Showing 1 changed file with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2110,21 +2110,42 @@
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

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
describe ".ps_manager on non-Windows" do

Check failure on line 2113 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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

Check failure on line 2113 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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
before do
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

Check failure on line 2119 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/TrailingWhitespace: Trailing whitespace detected.

Check failure on line 2119 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/TrailingWhitespace: Trailing whitespace detected.
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

Check failure on line 2125 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/TrailingWhitespace: Trailing whitespace detected.

Check failure on line 2125 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/TrailingWhitespace: Trailing whitespace detected.
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

Check failure on line 2131 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/EmptyLineAfterExampleGroup: Add an empty line after `describe`.

Check failure on line 2131 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/EmptyLineAfterExampleGroup: Add an empty line after `describe`.
describe ".ps_manager on Windows" do

Check failure on line 2132 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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

Check failure on line 2132 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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
before do
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 2137 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`.

Check failure on line 2137 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`.
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
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 63b9887

Please sign in to comment.