summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-02-13 00:29:07 -0600
committerJames Turnbull <james@lovedthanlost.net>2009-02-28 09:16:42 +1100
commitfa6494b69ad1b01a9c587c86aa1731f4702f5509 (patch)
tree5a8aaa6c15aca51fdcb6fde067aa4d7cb73f30e2 /spec/unit
parent373d505c381696f880c305a9357a6e50342079b8 (diff)
downloadpuppet-fa6494b69ad1b01a9c587c86aa1731f4702f5509.tar.gz
puppet-fa6494b69ad1b01a9c587c86aa1731f4702f5509.tar.xz
puppet-fa6494b69ad1b01a9c587c86aa1731f4702f5509.zip
Using the FileCollection where appropriate.
This commit just replaces the :file and :line accessors with the use of the new FileCollection Lookup module. This should mean that we've normalized all file names in a given process, which *might* have drastic RAM improvements. For initial simplicity, I've gone with a single global collection of file names, but it's built so it's easy to use individual file collections instead. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/file_collection.rb8
-rwxr-xr-xspec/unit/file_collection/lookup.rb7
-rw-r--r--spec/unit/parser/ast.rb6
-rwxr-xr-xspec/unit/parser/resource.rb4
-rwxr-xr-xspec/unit/parser/resource/reference.rb4
5 files changed, 27 insertions, 2 deletions
diff --git a/spec/unit/file_collection.rb b/spec/unit/file_collection.rb
index e9acc8dd2..81bcc2d2d 100755
--- a/spec/unit/file_collection.rb
+++ b/spec/unit/file_collection.rb
@@ -42,4 +42,12 @@ describe Puppet::FileCollection do
it "should return nil as the file name when an unknown index is provided" do
@collection.path(50).should be_nil
end
+
+ it "should provide a global collection" do
+ Puppet::FileCollection.collection.should be_instance_of(Puppet::FileCollection)
+ end
+
+ it "should reuse the global collection" do
+ Puppet::FileCollection.collection.should equal(Puppet::FileCollection.collection)
+ end
end
diff --git a/spec/unit/file_collection/lookup.rb b/spec/unit/file_collection/lookup.rb
index 9ae7ae582..81cc61872 100755
--- a/spec/unit/file_collection/lookup.rb
+++ b/spec/unit/file_collection/lookup.rb
@@ -12,7 +12,7 @@ describe Puppet::FileCollection::Lookup do
@tester = LookupTester.new
@file_collection = mock 'file_collection'
- @tester.stubs(:file_collection).returns @file_collection
+ Puppet::FileCollection.stubs(:collection).returns @file_collection
end
it "should use the file collection to determine the index of the file name" do
@@ -38,4 +38,9 @@ describe Puppet::FileCollection::Lookup do
@tester.line = 50
@tester.line.should == 50
end
+
+ it "should default to the global file collection" do
+ Puppet::FileCollection.expects(:collection).returns "collection"
+ @tester.file_collection.should == "collection"
+ end
end
diff --git a/spec/unit/parser/ast.rb b/spec/unit/parser/ast.rb
index 513943725..35e2b1eff 100644
--- a/spec/unit/parser/ast.rb
+++ b/spec/unit/parser/ast.rb
@@ -5,6 +5,10 @@ require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/parser/ast'
describe Puppet::Parser::AST do
+
+ it "should use the file lookup module" do
+ Puppet::Parser::AST.ancestors.should be_include(Puppet::FileCollection::Lookup)
+ end
it "should have a doc accessor" do
ast = Puppet::Parser::AST.new({})
@@ -34,4 +38,4 @@ describe Puppet::Parser::AST do
end
end
-end \ No newline at end of file
+end
diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb
index 63cfbc2ed..2666f6461 100755
--- a/spec/unit/parser/resource.rb
+++ b/spec/unit/parser/resource.rb
@@ -44,6 +44,10 @@ describe Puppet::Parser::Resource do
end
end
+ it "should use the file lookup module" do
+ Puppet::Parser::Resource.ancestors.should be_include(Puppet::FileCollection::Lookup)
+ end
+
it "should be isomorphic if it is builtin and models an isomorphic type" do
Puppet::Type.type(:file).expects(:isomorphic?).returns(true)
@resource = Puppet::Parser::Resource.new(:type => "file", :title => "whatever", :scope => @scope, :source => @source).isomorphic?.should be_true
diff --git a/spec/unit/parser/resource/reference.rb b/spec/unit/parser/resource/reference.rb
index bb1452692..6284e67cc 100755
--- a/spec/unit/parser/resource/reference.rb
+++ b/spec/unit/parser/resource/reference.rb
@@ -7,6 +7,10 @@ describe Puppet::Parser::Resource::Reference do
@type = Puppet::Parser::Resource::Reference
end
+ it "should use the file lookup module" do
+ Puppet::Parser::Resource::Reference.ancestors.should be_include(Puppet::FileCollection::Lookup)
+ end
+
it "should require a type" do
proc { @type.new(:title => "yay") }.should raise_error(Puppet::DevError)
end