diff options
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/parser/scope.rb | 15 | ||||
| -rwxr-xr-x | spec/unit/resource/type.rb | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/spec/unit/parser/scope.rb b/spec/unit/parser/scope.rb index b14b2d3b6..4f30ff0cc 100755 --- a/spec/unit/parser/scope.rb +++ b/spec/unit/parser/scope.rb @@ -28,6 +28,21 @@ describe Puppet::Parser::Scope do @scope.class_scope(klass).should == "myscope" end + it "should be able to retrieve its parent module name from the source of its parent type" do + @topscope.source = Puppet::Resource::Type.new(:hostclass, :foo) + @topscope.source.module_name = "foo" + + @scope.parent_module_name.should == "foo" + end + + it "should return a nil parent module name if it has no parent" do + @topscope.parent_module_name.should be_nil + end + + it "should return a nil parent module name if its parent has no source" do + @scope.parent_module_name.should be_nil + end + # #620 - Nodes and classes should conflict, else classes don't get evaluated describe "when evaluating nodes and classes with the same name (#620)" do 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 |
