]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Add behavior example for anchor refresh propagation
authorJeff McCune <jeff@puppetlabs.com>
Fri, 12 Apr 2013 00:55:40 +0000 (17:55 -0700)
committerJeff McCune <jeff@puppetlabs.com>
Fri, 12 Apr 2013 00:55:40 +0000 (17:55 -0700)
Without this patch we don't have a spec test to make sure the anchor
resource type passes notify events along.  This patch addresses the
problem by using RSpec Puppet to build a catalog, apply the catalog,
then pull a resource out of the transaction and make sure the resource
was triggered.

spec/classes/anchor_spec.rb [new file with mode: 0644]

diff --git a/spec/classes/anchor_spec.rb b/spec/classes/anchor_spec.rb
new file mode 100644 (file)
index 0000000..2dd17de
--- /dev/null
@@ -0,0 +1,32 @@
+require 'puppet'
+require 'rspec-puppet'
+
+describe "anchorrefresh" do
+  let(:node) { 'testhost.example.com' }
+  let :pre_condition do
+    <<-ANCHORCLASS
+class anchored {
+  anchor { 'anchored::begin': }
+  ~> anchor { 'anchored::end': }
+}
+
+class anchorrefresh {
+  notify { 'first': }
+  ~> class { 'anchored': }
+  ~> anchor { 'final': }
+}
+    ANCHORCLASS
+  end
+
+  def apply_catalog_and_return_exec_rsrc
+    catalog = subject.to_ral
+    transaction = catalog.apply
+    transaction.resource_status("Anchor[final]")
+  end
+
+  it 'propagates events through the anchored class' do
+    resource = apply_catalog_and_return_exec_rsrc
+
+    expect(resource.restarted).to eq(true)
+  end
+end