summaryrefslogtreecommitdiffstats
path: root/spec/unit/resource
diff options
context:
space:
mode:
authorLuke Kanies <luke@puppetlabs.com>2010-06-10 19:21:05 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit50a626daa1bef956ea63c405fddeaeab8a9a0756 (patch)
tree88a8fcf4ed68351a85935cef65a938a97c5513aa /spec/unit/resource
parent5d1934bbb118c254ed99f5a625844ad7c9064d8e (diff)
Fixing #1545 - Adding 'caller_module_name' variable
This will produce the name of the module that a given resource is defined in, rather than the module that the resource type itself is defined in. For instance: # in one/manifests/onedef.pp define one::onedef { notice "Called $name from $caller_module_name" } # in two/manifests/init.pp class two { one::onedef { yay: } } produces: Called yay from two This could obviously be extended to actually build a caller stack, as frightening as that seems. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Diffstat (limited to 'spec/unit/resource')
-rwxr-xr-xspec/unit/resource/type.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/unit/resource/type.rb b/spec/unit/resource/type.rb
index 59e46238e..3d0e82498 100755
--- a/spec/unit/resource/type.rb
+++ b/spec/unit/resource/type.rb
@@ -322,6 +322,14 @@ describe Puppet::Resource::Type do
@scope.lookupvar("module_name").should == "mymod"
end
+
+ it "should set its caller module name in the scope if available" do
+ @scope.expects(:parent_module_name).returns "mycaller"
+
+ @type.set_resource_parameters(@resource, @scope)
+
+ @scope.lookupvar("caller_module_name").should == "mycaller"
+ end
end
describe "when describing and managing parent classes" do