diff --git a/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb b/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb index cb4bce4..149f2e0 100755 --- a/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb +++ b/spec/unit/puppet/provider/rsyslog_filter/augeas_spec.rb @@ -11,10 +11,10 @@ let(:target) { tmptarget.path } it 'creates new entry with file' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:rsyslog_filter).new( name: 'my test', @@ -36,10 +36,10 @@ end it 'creates new entry with protocol/hostname/port' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:rsyslog_filter).new( name: 'my test', @@ -68,12 +68,12 @@ let(:target) { tmptarget.path } it 'lists instances' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) - provider_class.stubs(:target).returns(target) + allow(provider_class).to receive(:target).and_return(target) inst = provider_class.instances.map do |p| { name: p.get(:name), @@ -104,10 +104,10 @@ describe 'when creating settings' do it 'creates a simple new entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:rsyslog_filter).new( name: 'my test', @@ -129,10 +129,10 @@ describe 'when modifying settings' do it 'uses file' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:rsyslog_filter).new( name: 'ssh', @@ -154,10 +154,10 @@ describe 'when removing settings' do it 'removes the entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:rsyslog_filter).new( name: 'ssh', @@ -183,10 +183,10 @@ let(:target) { tmptarget.path } it 'fails to load' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) txn = apply(Puppet::Type.type(:rsyslog_filter).new( name: 'ssh', diff --git a/spec/unit/puppet/provider/syslog/augeas_spec.rb b/spec/unit/puppet/provider/syslog/augeas_spec.rb index ec1844b..8b6b68e 100755 --- a/spec/unit/puppet/provider/syslog/augeas_spec.rb +++ b/spec/unit/puppet/provider/syslog/augeas_spec.rb @@ -11,10 +11,10 @@ let(:target) { tmptarget.path } it 'creates simple new entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'my test', @@ -35,10 +35,10 @@ end it 'creates hostname entry with tcp protocol' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) if protocol_supported apply!(Puppet::Type.type(:syslog).new( @@ -77,10 +77,10 @@ end it 'creates hostname entry with udp protocol' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) if protocol_supported == :stock apply!(Puppet::Type.type(:syslog).new( @@ -137,10 +137,10 @@ end it 'creates hostname entry with port' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) if protocol_supported # port requires protocol apply!(Puppet::Type.type(:syslog).new( @@ -186,12 +186,12 @@ let(:target) { tmptarget.path } it 'lists instances' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) - provider_class.stubs(:target).returns(target) + allow(provider_class).to receive(:target).and_return(target) inst = provider_class.instances.map do |p| { name: p.get(:name), @@ -216,10 +216,10 @@ describe 'when creating settings' do it 'creates a simple new entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'my test', @@ -241,10 +241,10 @@ describe 'when modifying settings' do it 'adds a no_sync flag' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'cron.*', @@ -264,10 +264,10 @@ end it 'removes the no_sync flag' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'mail.*', @@ -289,10 +289,10 @@ describe 'when removing settings' do it 'removes the entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'mail.*', @@ -317,10 +317,10 @@ let(:target) { tmptarget.path } it 'fails to load' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/syslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) txn = apply(Puppet::Type.type(:syslog).new( name: 'mail.*', diff --git a/spec/unit/puppet/provider/syslog/rsyslog_spec.rb b/spec/unit/puppet/provider/syslog/rsyslog_spec.rb index 61fa9cb..e129d57 100755 --- a/spec/unit/puppet/provider/syslog/rsyslog_spec.rb +++ b/spec/unit/puppet/provider/syslog/rsyslog_spec.rb @@ -16,10 +16,10 @@ def valid_lens? let(:target) { tmptarget.path } it 'creates simple new entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'my test', @@ -40,10 +40,10 @@ def valid_lens? end it 'creates hostname entry with tcp protocol' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) if protocol_supported apply!(Puppet::Type.type(:syslog).new( @@ -82,10 +82,10 @@ def valid_lens? end it 'creates hostname entry with udp protocol' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) if protocol_supported == :stock apply!(Puppet::Type.type(:syslog).new( @@ -142,10 +142,10 @@ def valid_lens? end it 'creates hostname entry with port' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) if protocol_supported # port requires protocol apply!(Puppet::Type.type(:syslog).new( @@ -191,12 +191,12 @@ def valid_lens? let(:target) { tmptarget.path } it 'lists instances' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) - provider_class.stubs(:target).returns(target) + allow(provider_class).to receive(:target).and_return(target) inst = provider_class.instances.map do |p| { name: p.get(:name), @@ -241,10 +241,10 @@ def valid_lens? describe 'when modifying settings' do it 'adds a no_sync flag' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'cron.*', @@ -264,10 +264,10 @@ def valid_lens? end it 'removes the no_sync flag' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'mail.*', @@ -289,10 +289,10 @@ def valid_lens? describe 'when removing settings' do it 'removes the entry' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) apply!(Puppet::Type.type(:syslog).new( name: 'mail.*', @@ -317,10 +317,10 @@ def valid_lens? let(:target) { tmptarget.path } it 'fails to load' do - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true - FileTest.stubs(:exist?).returns false - FileTest.stubs(:exist?).with('/etc/rsyslog.conf').returns true + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) + allow(FileTest).to receive(:exist?).and_return(false) + allow(FileTest).to receive(:exist?).with('/etc/rsyslog.conf').and_return(true) txn = apply(Puppet::Type.type(:syslog).new( name: 'mail.*',