Sha256: 24822c9d36777fa5c7e282842e666e5fbb42c39b5b2d9712c1308382d3d81442

Contents?: true

Size: 1.54 KB

Versions: 20

Compression:

Stored size: 1.54 KB

Contents

#!/usr/bin/env ruby

require 'spec_helper'

describe 'Puppet::Type::Service::Provider::Rcng',
    :unless => Puppet::Util::Platform.windows? || Puppet::Util::Platform.jruby? do
  let(:provider_class) { Puppet::Type.type(:service).provider(:rcng) }

  before :each do
    Puppet::Type.type(:service).stubs(:defaultprovider).returns provider_class
    Facter.stubs(:value).with(:operatingsystem).returns :netbsd
    Facter.stubs(:value).with(:osfamily).returns 'NetBSD'
    provider_class.stubs(:defpath).returns('/etc/rc.d')
    @provider = provider_class.new
    @provider.stubs(:initscript)
  end

  describe "#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 = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
      Dir.stubs(:mkdir).with('/etc/rc.conf.d')
      fh = stub 'fh'
      Puppet::Util.expects(:replace_file).with('/etc/rc.conf.d/sshd', 0644).yields(fh)
      fh.expects(:puts).with("sshd=${sshd:=YES}\n")
      provider.enable
    end

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-6.0.4 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.4-x86-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.4-x64-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.4-universal-darwin spec/unit/provider/service/rcng_spec.rb
puppet-6.0.3 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.3-x86-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.3-x64-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.3-universal-darwin spec/unit/provider/service/rcng_spec.rb
puppet-6.0.2 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.2-x86-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.2-x64-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.2-universal-darwin spec/unit/provider/service/rcng_spec.rb
puppet-6.0.1 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.1-x86-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.1-x64-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.1-universal-darwin spec/unit/provider/service/rcng_spec.rb
puppet-6.0.0 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.0-x86-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.0-x64-mingw32 spec/unit/provider/service/rcng_spec.rb
puppet-6.0.0-universal-darwin spec/unit/provider/service/rcng_spec.rb