summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-01-04 17:02:28 -0800
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit201889bd30260698478d8469517299b290053189 (patch)
tree8269d03590d76debd568f1b309c58e2e6d0a31b1 /spec/unit/parser
parent2c2b3c27e242f7ee99354c7d4f0d2a18d5710f49 (diff)
downloadpuppet-201889bd30260698478d8469517299b290053189.tar.gz
puppet-201889bd30260698478d8469517299b290053189.tar.xz
puppet-201889bd30260698478d8469517299b290053189.zip
Renaming LoadedCode to ResourceTypeCollection
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'spec/unit/parser')
-rwxr-xr-xspec/unit/parser/parser.rb32
-rwxr-xr-xspec/unit/parser/resource_type.rb6
-rw-r--r--spec/unit/parser/resource_type_collection.rb (renamed from spec/unit/parser/loaded_code.rb)62
3 files changed, 50 insertions, 50 deletions
diff --git a/spec/unit/parser/parser.rb b/spec/unit/parser/parser.rb
index f10517fd7..16e469fd8 100755
--- a/spec/unit/parser/parser.rb
+++ b/spec/unit/parser/parser.rb
@@ -7,8 +7,8 @@ describe Puppet::Parser do
ast = Puppet::Parser::AST
before :each do
- @loaded_code = Puppet::Parser::LoadedCode.new
- @parser = Puppet::Parser::Parser.new :environment => "development", :loaded_code => @loaded_code
+ @resource_type_collection = Puppet::Parser::ResourceTypeCollection.new("development")
+ @parser = Puppet::Parser::Parser.new :environment => "development", :resource_type_collection => @resource_type_collection
@true_ast = Puppet::Parser::AST::Boolean.new :value => true
end
@@ -275,8 +275,8 @@ describe Puppet::Parser do
end
describe "when retrieving a specific node" do
- it "should delegate to the loaded_code node" do
- @loaded_code.expects(:node).with("node")
+ it "should delegate to the resource_type_collection node" do
+ @resource_type_collection.expects(:node).with("node")
@parser.node("node")
end
@@ -284,7 +284,7 @@ describe Puppet::Parser do
describe "when retrieving a specific class" do
it "should delegate to the loaded code" do
- @loaded_code.expects(:hostclass).with("class")
+ @resource_type_collection.expects(:hostclass).with("class")
@parser.hostclass("class")
end
@@ -292,7 +292,7 @@ describe Puppet::Parser do
describe "when retrieving a specific definitions" do
it "should delegate to the loaded code" do
- @loaded_code.expects(:definition).with("define")
+ @resource_type_collection.expects(:definition).with("define")
@parser.definition("define")
end
@@ -338,10 +338,10 @@ describe Puppet::Parser do
describe "when looking up names" do
before :each do
- @loaded_code = mock 'loaded code'
- @loaded_code.stubs(:find_my_type).with('loaded_namespace', 'loaded_name').returns(true)
- @loaded_code.stubs(:find_my_type).with('bogus_namespace', 'bogus_name' ).returns(false)
- @parser = Puppet::Parser::Parser.new :environment => "development",:loaded_code => @loaded_code
+ @resource_type_collection = mock 'loaded code'
+ @resource_type_collection.stubs(:find_my_type).with('loaded_namespace', 'loaded_name').returns(true)
+ @resource_type_collection.stubs(:find_my_type).with('bogus_namespace', 'bogus_name' ).returns(false)
+ @parser = Puppet::Parser::Parser.new :environment => "development",:resource_type_collection => @resource_type_collection
end
describe "that are already loaded" do
@@ -356,20 +356,20 @@ describe Puppet::Parser do
describe "that aren't already loaded" do
it "should first attempt to load them with the all lowercase fully qualified name" do
- @loaded_code.stubs(:find_my_type).with("foo_namespace","foo_name").returns(false,true,true)
+ @resource_type_collection.stubs(:find_my_type).with("foo_namespace","foo_name").returns(false,true,true)
@parser.expects(:load).with("foo_namespace::foo_name").returns(true).then.raises(Exception)
@parser.find_or_load("Foo_namespace","Foo_name",:my_type).should == true
end
it "should next attempt to load them with the all lowercase namespace" do
- @loaded_code.stubs(:find_my_type).with("foo_namespace","foo_name").returns(false,false,true,true)
+ @resource_type_collection.stubs(:find_my_type).with("foo_namespace","foo_name").returns(false,false,true,true)
@parser.expects(:load).with("foo_namespace::foo_name").returns(false).then.raises(Exception)
@parser.expects(:load).with("foo_namespace" ).returns(true ).then.raises(Exception)
@parser.find_or_load("Foo_namespace","Foo_name",:my_type).should == true
end
it "should finally attempt to load them with the all lowercase unqualified name" do
- @loaded_code.stubs(:find_my_type).with("foo_namespace","foo_name").returns(false,false,false,true,true)
+ @resource_type_collection.stubs(:find_my_type).with("foo_namespace","foo_name").returns(false,false,false,true,true)
@parser.expects(:load).with("foo_namespace::foo_name").returns(false).then.raises(Exception)
@parser.expects(:load).with("foo_namespace" ).returns(false).then.raises(Exception)
@parser.expects(:load).with( "foo_name").returns(true ).then.raises(Exception)
@@ -382,7 +382,7 @@ describe Puppet::Parser do
end
it "should directly look for fully qualified classes" do
- @loaded_code.stubs(:find_hostclass).with("foo_namespace","::foo_name").returns(false, true)
+ @resource_type_collection.stubs(:find_hostclass).with("foo_namespace","::foo_name").returns(false, true)
@parser.expects(:load).with("foo_name").returns true
@parser.find_or_load("foo_namespace","::foo_name",:hostclass)
end
@@ -391,8 +391,8 @@ describe Puppet::Parser do
describe "when loading classnames" do
before :each do
- @loaded_code = mock 'loaded code'
- @parser = Puppet::Parser::Parser.new :environment => "development",:loaded_code => @loaded_code
+ @resource_type_collection = mock 'loaded code'
+ @parser = Puppet::Parser::Parser.new :environment => "development",:resource_type_collection => @resource_type_collection
end
it "should just return false if the classname is empty" do
diff --git a/spec/unit/parser/resource_type.rb b/spec/unit/parser/resource_type.rb
index 08f7e2af0..8a8bfb5de 100755
--- a/spec/unit/parser/resource_type.rb
+++ b/spec/unit/parser/resource_type.rb
@@ -94,19 +94,19 @@ describe Puppet::Parser::ResourceType do
end
it "should return the name converted to a string when the name is not a regex" do
- pending "Need to define LoadedCode behaviour first"
+ pending "Need to define ResourceTypeCollection behaviour first"
name = Puppet::Parser::AST::HostName.new(:value => "foo")
Puppet::Parser::ResourceType.new(:node, name).name.should == "foo"
end
it "should return the name converted to a string when the name is a regex" do
- pending "Need to define LoadedCode behaviour first"
+ pending "Need to define ResourceTypeCollection behaviour first"
name = Puppet::Parser::AST::HostName.new(:value => /regex/)
Puppet::Parser::ResourceType.new(:node, name).name.should == /regex/.to_s
end
it "should mark any created scopes as a node scope" do
- pending "Need to define LoadedCode behaviour first"
+ pending "Need to define ResourceTypeCollection behaviour first"
name = Puppet::Parser::AST::HostName.new(:value => /regex/)
Puppet::Parser::ResourceType.new(:node, name).name.should == /regex/.to_s
end
diff --git a/spec/unit/parser/loaded_code.rb b/spec/unit/parser/resource_type_collection.rb
index 3a230f988..0d7795c3a 100644
--- a/spec/unit/parser/loaded_code.rb
+++ b/spec/unit/parser/resource_type_collection.rb
@@ -2,37 +2,37 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'puppet/parser/loaded_code'
+require 'puppet/parser/resource_type_collection'
require 'puppet/parser/resource_type'
-describe Puppet::Parser::LoadedCode do
+describe Puppet::Parser::ResourceTypeCollection do
before do
@instance = Puppet::Parser::ResourceType.new(:hostclass, "foo")
- @code = Puppet::Parser::LoadedCode.new("env")
+ @code = Puppet::Parser::ResourceTypeCollection.new("env")
end
it "should require an environment at initialization" do
- Puppet::Parser::LoadedCode.new("foo").environment.should == "foo"
+ Puppet::Parser::ResourceTypeCollection.new("foo").environment.should == "foo"
end
it "should store itself as the environment-specific code collection in its class" do
- code = Puppet::Parser::LoadedCode.new("foo")
- Puppet::Parser::LoadedCode["foo"].should equal(code)
+ code = Puppet::Parser::ResourceTypeCollection.new("foo")
+ Puppet::Parser::ResourceTypeCollection["foo"].should equal(code)
end
it "should be able to add a resource type" do
- Puppet::Parser::LoadedCode.new("env").should respond_to(:add)
+ Puppet::Parser::ResourceTypeCollection.new("env").should respond_to(:add)
end
it "should consider '<<' to be an alias to 'add' but should return self" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
loader.expects(:add).with "foo"
loader.expects(:add).with "bar"
loader << "foo" << "bar"
end
it "should set itself as the code collection for added resource types" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
node = Puppet::Parser::ResourceType.new(:node, "foo")
@@ -65,48 +65,48 @@ describe Puppet::Parser::LoadedCode do
%w{hostclass node definition}.each do |data|
it "should have a method for adding a #{data}" do
- Puppet::Parser::LoadedCode.new("env").should respond_to("add_" + data)
+ Puppet::Parser::ResourceTypeCollection.new("env").should respond_to("add_" + data)
end
it "should use the name of the instance to add it" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
loader.send("add_#{data}", @instance)
loader.send(data, @instance.name).should equal(@instance)
end
it "should fail to add a #{data} when one already exists" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
loader.add @instance
lambda { loader.add(@instance) }.should raise_error(Puppet::ParseError)
end
it "should return the added #{data}" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
loader.add(@instance).should equal(@instance)
end
it "should be able to retrieve #{data} by name" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
instance = Puppet::Parser::ResourceType.new(data, "bar")
loader.add instance
loader.send(data, "bar").should equal(instance)
end
it "should retrieve #{data} insensitive to case" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
instance = Puppet::Parser::ResourceType.new(data, "Bar")
loader.add instance
loader.send(data, "bAr").should equal(instance)
end
it "should return nil when asked for a #{data} that has not been added" do
- Puppet::Parser::LoadedCode.new("env").send(data, "foo").should be_nil
+ Puppet::Parser::ResourceTypeCollection.new("env").send(data, "foo").should be_nil
end
it "should be able to retrieve all #{data}s" do
plurals = { "hostclass" => "hostclasses", "node" => "nodes", "definition" => "definitions" }
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
instance = Puppet::Parser::ResourceType.new(data, "foo")
loader.add instance
loader.send(plurals[data]).should == { "foo" => instance }
@@ -115,54 +115,54 @@ describe Puppet::Parser::LoadedCode do
describe "when finding a qualified instance" do
it "should return any found instance if the instance name is fully qualified" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
instance = Puppet::Parser::ResourceType.new(:hostclass, "foo::bar")
loader.add instance
loader.find("namespace", "::foo::bar", :hostclass).should equal(instance)
end
it "should return nil if the instance name is fully qualified and no such instance exists" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
loader.find("namespace", "::foo::bar", :hostclass).should be_nil
end
it "should return the partially qualified object if it exists in the provided namespace" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
instance = Puppet::Parser::ResourceType.new(:hostclass, "foo::bar::baz")
loader.add instance
loader.find("foo", "bar::baz", :hostclass).should equal(instance)
end
it "should return the unqualified object if it exists in the provided namespace" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
instance = Puppet::Parser::ResourceType.new(:hostclass, "foo::bar")
loader.add instance
loader.find("foo", "bar", :hostclass).should equal(instance)
end
it "should return the unqualified object if it exists in the parent namespace" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
instance = Puppet::Parser::ResourceType.new(:hostclass, "foo::bar")
loader.add instance
loader.find("foo::bar::baz", "bar", :hostclass).should equal(instance)
end
it "should should return the partially qualified object if it exists in the parent namespace" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
instance = Puppet::Parser::ResourceType.new(:hostclass, "foo::bar::baz")
loader.add instance
loader.find("foo::bar", "bar::baz", :hostclass).should equal(instance)
end
it "should return the qualified object if it exists in the root namespace" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
instance = Puppet::Parser::ResourceType.new(:hostclass, "foo::bar::baz")
loader.add instance
loader.find("foo::bar", "foo::bar::baz", :hostclass).should equal(instance)
end
it "should return nil if the object cannot be found" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
instance = Puppet::Parser::ResourceType.new(:hostclass, "foo::bar::baz")
loader.add instance
loader.find("foo::bar", "eh", :hostclass).should be_nil
@@ -170,36 +170,36 @@ describe Puppet::Parser::LoadedCode do
end
it "should use the generic 'find' method with an empty namespace to find nodes" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
loader.expects(:find).with("", "bar", :node)
loader.find_node("bar")
end
it "should use the generic 'find' method to find hostclasses" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
loader.expects(:find).with("foo", "bar", :hostclass)
loader.find_hostclass("foo", "bar")
end
it "should use the generic 'find' method to find definitions" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
loader.expects(:find).with("foo", "bar", :definition)
loader.find_definition("foo", "bar")
end
it "should indicate whether any nodes are defined" do
- loader = Puppet::Parser::LoadedCode.new("env")
+ loader = Puppet::Parser::ResourceTypeCollection.new("env")
loader.add_node(Puppet::Parser::ResourceType.new(:node, "foo"))
loader.should be_nodes
end
it "should indicate whether no nodes are defined" do
- Puppet::Parser::LoadedCode.new("env").should_not be_nodes
+ Puppet::Parser::ResourceTypeCollection.new("env").should_not be_nodes
end
describe "when finding nodes" do
before :each do
- @loader = Puppet::Parser::LoadedCode.new("env")
+ @loader = Puppet::Parser::ResourceTypeCollection.new("env")
end
it "should return any node whose name exactly matches the provided node name" do