Projet

Général

Profil

Révision 232c1364

ID232c1364e508086f07248413014196336e966d8a
Parent 5679c81e
Enfant 435a5db2

Ajouté par Steve Traylen il y a environ 3 ans

Migrate from deprecated mocha

Voir les différences:

.sync.yml
1 1
---
2
spec/spec_helper.rb:
3
  mock_with: ':mocha'
4 2

  
5 3
spec/spec_helper_acceptance.rb:
6 4
  unmanaged: false
spec/spec_helper.rb
4 4
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
5 5

  
6 6
RSpec.configure do |c|
7
  c.mock_with :mocha
8 7
end
9 8

  
10 9
# puppetlabs_spec_helper will set up coverage if the env variable is set.
spec/unit/facter/nftables_spec.rb
5 5
describe 'nftables' do
6 6
  before do
7 7
    Facter.clear
8
    Process.stubs(:uid).returns(0)
9
    Facter::Util::Resolution.stubs(:which).with('nft').returns('/usr/sbin/nft')
10
    Facter::Core::Execution.stubs(:execute).with('/usr/sbin/nft list tables').returns(nft_tables_result)
11
    Facter::Core::Execution.stubs(:execute).with('/usr/sbin/nft --version').returns(nft_version_result)
8
    allow(Process).to receive(:uid).and_return(0)
9
    allow(Facter::Util::Resolution).to receive(:which).with('nft').and_return('/usr/sbin/nft')
10
    allow(Facter::Core::Execution).to receive(:execute).with('/usr/sbin/nft list tables').and_return(nft_tables_result)
11
    allow(Facter::Core::Execution).to receive(:execute).with('/usr/sbin/nft --version').and_return(nft_version_result)
12 12
  end
13 13

  
14 14
  context 'nft present' do
......
25 25
    let(:nft_version_result) { :failed }
26 26

  
27 27
    it 'does not return a fact' do
28
      Facter::Core::Execution.stubs(:execute).with('/usr/sbin/nft --version', on_fail: :failed).returns(:failed)
29
      Facter::Core::Execution.stubs(:execute).with('/usr/sbin/nft list tables', on_fail: :failed).returns(:failed)
28
      allow(Facter::Core::Execution).to receive(:execute).with('/usr/sbin/nft --version', onfail: :failed).and_return(:failed)
29
      allow(Facter::Core::Execution).to receive(:execute).with('/usr/sbin/nft list tables', onfail: :failed).and_return(:failed)
30 30

  
31 31
      expect(Facter.fact('nftables').value).to be_nil
32 32
    end

Formats disponibles : Unified diff