Skip to content

Commit

Permalink
Replacing anchor functionality with contain
Browse files Browse the repository at this point in the history
  • Loading branch information
Helen Campbell authored and DavidS committed Oct 26, 2016
1 parent 25ee1eb commit 77fbf3f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
13 changes: 8 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@
# Anchor this as per #8040 - this ensures that classes won't float off and
# mess everything up. You can read about this at:
# http://docs.puppetlabs.com/puppet/2.7/reference/lang_containment.html#known-issues
anchor { 'ntp::begin': } ->
class { '::ntp::install': } ->
class { '::ntp::config': } ~>
class { '::ntp::service': } ->
anchor { 'ntp::end': }

contain ntp::install
contain ntp::config
contain ntp::service

Class['::ntp::install'] ->
Class['::ntp::config'] ~>
Class['::ntp::service']
}
28 changes: 28 additions & 0 deletions spec/classes/contains_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# To check the correct dependancies are set up for NTP.

require 'spec_helper'
describe 'ntp' do
let(:facts) {{ :is_virtual => 'false' }}
let :pre_condition do
'file { "foo.rb":
ensure => present,
path => "/etc/tmp",
notify => Service["ntp"] }' end
on_supported_os.select { |_, f| f[:os]['family'] != 'Solaris' }.each do |os, f|
context "on #{os}" do
let(:facts) do
f.merge(super())
end

it { is_expected.to compile.with_all_deps }
describe "Testing the dependancies between the classes" do
it { should contain_class('ntp::install') }
it { should contain_class('ntp::config') }
it { should contain_class('ntp::service') }
it { is_expected.to contain_class('ntp::install').that_comes_before('Class[ntp::config]') }
it { is_expected.to contain_class('ntp::service').that_subscribes_to('Class[ntp::config]') }
it { is_expected.to contain_file('foo.rb').that_notifies('Service[ntp]') }
end
end
end
end

0 comments on commit 77fbf3f

Please sign in to comment.