Sha256: 28db5a810ccf7b33c16ddbb888158f1632701044e0e1e7d211f1f0b47d524869

Contents?: true

Size: 1.58 KB

Versions: 36

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe Puppet::Type.type(:service).provider(:rcng), :unless => Puppet.features.microsoft_windows? do
  before :each do
    allow(Puppet::Type.type(:service)).to receive(:defaultprovider).and_return(described_class)
    allow(Facter).to receive(:value).with(:operatingsystem).and_return(:netbsd)
    allow(Facter).to receive(:value).with(:osfamily).and_return('NetBSD')
    allow(described_class).to receive(:defpath).and_return('/etc/rc.d')
    @provider = subject()
    allow(@provider).to receive(:initscript)
  end

  context "#enable" do
    it "should have an enable method" do
      expect(@provider).to respond_to(:enable)
    end

    it "should set the proper contents to enable" do
      provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
      allow(Dir).to receive(:mkdir).with('/etc/rc.conf.d')
      fh = double('fh')
      expect(Puppet::Util).to receive(:replace_file).with('/etc/rc.conf.d/sshd', 0644).and_yield(fh)
      expect(fh).to receive(:puts).with("sshd=${sshd:=YES}\n")
      provider.enable
    end

    it "should set the proper contents to enable when disabled" do
      provider = described_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
      allow(Dir).to receive(:mkdir).with('/etc/rc.conf.d')
      allow(File).to receive(:read).with('/etc/rc.conf.d/sshd').and_return("sshd_enable=\"NO\"\n")
      fh = double('fh')
      expect(Puppet::Util).to receive(:replace_file).with('/etc/rc.conf.d/sshd', 0644).and_yield(fh)
      expect(fh).to receive(:puts).with("sshd=${sshd:=YES}\n")
      provider.enable
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
puppet-5.5.22 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.22-x86-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.22-x64-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.22-universal-darwin spec/unit/provider/service/rcng_spec.rb
puppet-5.5.21 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.21-x86-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.21-x64-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.21-universal-darwin spec/unit/provider/service/rcng_spec.rb
puppet-5.5.20 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.20-x86-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.20-x64-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.20-universal-darwin spec/unit/provider/service/rcng_spec.rb
puppet-5.5.19 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.19-x86-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.19-x64-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.19-universal-darwin spec/unit/provider/service/rcng_spec.rb
puppet-5.5.18 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.18-x86-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.18-x64-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-5.5.18-universal-darwin spec/unit/provider/service/rcng_spec.rb