summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-07-28 14:54:23 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-07-30 14:28:31 -0700
commit6dbd4771265173a9d4c3e7756c35c9ca371ca394 (patch)
tree835faf9ed49da69b9d2059ed1ebba8cde485d21d /spec/unit/parser
parent871e6fd58223cad241bcc14f165b3ab1e6e257e6 (diff)
downloadpuppet-6dbd4771265173a9d4c3e7756c35c9ca371ca394.tar.gz
puppet-6dbd4771265173a9d4c3e7756c35c9ca371ca394.tar.xz
puppet-6dbd4771265173a9d4c3e7756c35c9ca371ca394.zip
[#4397]+[#4344] Move type-name resolution out of Puppet::Resource into the AST resources.
Move type-name resolution out of Puppet::Resource into the AST resources. Move find_resource_type out of Puppet::Resource into Scope Thus, never pass unqualified type names to Puppet::Resource objects. Thus, Puppet::Resource objects don't need the namespace property, and Puppet::Resource objects never consult the harddrive to look for .pp files that might contain their type definitions, Thus, performance is improved. Also removes the temporary fix for #4257 that caused #4397 (The code was too eager to look for a class in the topscope) Paired-With: Paul Berry <paul@puppetlabs.com> Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Diffstat (limited to 'spec/unit/parser')
-rwxr-xr-xspec/unit/parser/ast/resource_reference_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/require_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/tag_spec.rb1
-rwxr-xr-xspec/unit/parser/resource_spec.rb12
4 files changed, 5 insertions, 15 deletions
diff --git a/spec/unit/parser/ast/resource_reference_spec.rb b/spec/unit/parser/ast/resource_reference_spec.rb
index 7b48119f4..93419d963 100755
--- a/spec/unit/parser/ast/resource_reference_spec.rb
+++ b/spec/unit/parser/ast/resource_reference_spec.rb
@@ -32,11 +32,6 @@ describe Puppet::Parser::AST::ResourceReference do
]
end
- it "should pass its scope's namespaces to all created resource references" do
- @scope.add_namespace "foo"
- newref("File", "/tmp/yay").evaluate(@scope).namespaces.should == ["foo"]
- end
-
it "should return a correct representation when converting to string" do
type = stub 'type', :is_a? => true, :to_s => "file"
title = stub 'title', :is_a? => true, :to_s => "[/tmp/a, /tmp/b]"
diff --git a/spec/unit/parser/functions/require_spec.rb b/spec/unit/parser/functions/require_spec.rb
index bd42fa579..49c4bbf74 100755
--- a/spec/unit/parser/functions/require_spec.rb
+++ b/spec/unit/parser/functions/require_spec.rb
@@ -6,7 +6,7 @@ describe "the require function" do
before :each do
@catalog = stub 'catalog'
- @compiler = stub 'compiler', :catalog => @catalog
+ @compiler = stub 'compiler', :catalog => @catalog, :environment => nil
@scope = Puppet::Parser::Scope.new
@scope.stubs(:findresource)
diff --git a/spec/unit/parser/functions/tag_spec.rb b/spec/unit/parser/functions/tag_spec.rb
index ff37badbb..dac134134 100755
--- a/spec/unit/parser/functions/tag_spec.rb
+++ b/spec/unit/parser/functions/tag_spec.rb
@@ -6,6 +6,7 @@ describe "the 'tag' function" do
before :each do
@scope = Puppet::Parser::Scope.new
+ @scope.stubs(:environment).returns(nil)
end
it "should exist" do
diff --git a/spec/unit/parser/resource_spec.rb b/spec/unit/parser/resource_spec.rb
index da49940b0..dae22fcaa 100755
--- a/spec/unit/parser/resource_spec.rb
+++ b/spec/unit/parser/resource_spec.rb
@@ -58,23 +58,17 @@ describe Puppet::Parser::Resource do
end
it "should get its environment from its scope" do
- scope = stub 'scope', :source => stub("source")
- scope.expects(:environment).returns "foo"
+ scope = stub 'scope', :source => stub("source"), :namespaces => nil
+ scope.expects(:environment).returns("foo").at_least_once
Puppet::Parser::Resource.new("file", "whatever", :scope => scope).environment.should == "foo"
end
- it "should get its namespaces from its scope" do
- scope = stub 'scope', :source => stub("source")
- scope.expects(:namespaces).returns %w{one two}
- Puppet::Parser::Resource.new("file", "whatever", :scope => scope).namespaces.should == %w{one two}
- end
-
it "should use the resource type collection helper module" do
Puppet::Parser::Resource.ancestors.should be_include(Puppet::Resource::TypeCollectionHelper)
end
it "should use the scope's environment as its environment" do
- @scope.expects(:environment).returns "myenv"
+ @scope.expects(:environment).returns("myenv").at_least_once
Puppet::Parser::Resource.new("file", "whatever", :scope => @scope).environment.should == "myenv"
end