summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser
diff options
context:
space:
mode:
authorDominic Cleal <dcleal@redhat.com>2011-02-19 21:21:13 +0000
committerDominic Cleal <dcleal@redhat.com>2011-02-19 21:21:13 +0000
commitc87ec2598700c4e5236452a016f0497ec848cb90 (patch)
tree47a2435ef019bfcac2ec2aa388935173bc5c6b52 /spec/unit/parser
parent3eace859f20d9ac7366382826028af44c3ab62d6 (diff)
parentea348761df0b5297dbac50c7f1c48d22746524fa (diff)
downloadpuppet-c87ec2598700c4e5236452a016f0497ec848cb90.tar.gz
puppet-c87ec2598700c4e5236452a016f0497ec848cb90.tar.xz
puppet-c87ec2598700c4e5236452a016f0497ec848cb90.zip
Merge branch 'master' into tickets/master/4258-dev
Diffstat (limited to 'spec/unit/parser')
-rwxr-xr-xspec/unit/parser/ast/arithmetic_operator_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/astarray_spec.rb2
-rw-r--r--spec/unit/parser/ast/asthash_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/boolean_operator_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/casestatement_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/collection_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/collexpr_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/comparison_operator_spec.rb2
-rw-r--r--spec/unit/parser/ast/definition_spec.rb2
-rw-r--r--spec/unit/parser/ast/function_spec.rb2
-rw-r--r--spec/unit/parser/ast/hostclass_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/ifstatement_spec.rb2
-rw-r--r--spec/unit/parser/ast/in_operator_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/leaf_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/match_operator_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/minus_spec.rb2
-rw-r--r--spec/unit/parser/ast/node_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/nop_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/not_spec.rb2
-rw-r--r--spec/unit/parser/ast/relationship_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/resource_defaults_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/resource_override_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/resource_reference_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/resource_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/selector_spec.rb2
-rwxr-xr-xspec/unit/parser/ast/vardef_spec.rb2
-rw-r--r--spec/unit/parser/ast_spec.rb2
-rwxr-xr-xspec/unit/parser/collector_spec.rb10
-rwxr-xr-xspec/unit/parser/compiler_spec.rb97
-rw-r--r--spec/unit/parser/files_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/defined_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/extlookup_spec.rb2
-rw-r--r--spec/unit/parser/functions/fqdn_rand_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/generate_spec.rb2
-rw-r--r--spec/unit/parser/functions/include_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/inline_template_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/realize_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/regsubst_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/require_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/shellquote_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/split_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/sprintf_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/tag_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/template_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/versioncmp_spec.rb2
-rw-r--r--spec/unit/parser/functions_spec.rb2
-rwxr-xr-xspec/unit/parser/lexer_spec.rb7
-rwxr-xr-xspec/unit/parser/parser_spec.rb2
-rw-r--r--spec/unit/parser/relationship_spec.rb2
-rwxr-xr-xspec/unit/parser/resource_spec.rb2
-rwxr-xr-xspec/unit/parser/scope_spec.rb2
-rwxr-xr-xspec/unit/parser/templatewrapper_spec.rb2
-rw-r--r--spec/unit/parser/type_loader_spec.rb2
53 files changed, 148 insertions, 66 deletions
diff --git a/spec/unit/parser/ast/arithmetic_operator_spec.rb b/spec/unit/parser/ast/arithmetic_operator_spec.rb
index 093cf94f1..381c5c629 100755
--- a/spec/unit/parser/ast/arithmetic_operator_spec.rb
+++ b/spec/unit/parser/ast/arithmetic_operator_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::ArithmeticOperator do
diff --git a/spec/unit/parser/ast/astarray_spec.rb b/spec/unit/parser/ast/astarray_spec.rb
index 8794848b6..01082b3f0 100755
--- a/spec/unit/parser/ast/astarray_spec.rb
+++ b/spec/unit/parser/ast/astarray_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::ASTArray do
before :each do
diff --git a/spec/unit/parser/ast/asthash_spec.rb b/spec/unit/parser/ast/asthash_spec.rb
index c70553c56..83f604545 100644
--- a/spec/unit/parser/ast/asthash_spec.rb
+++ b/spec/unit/parser/ast/asthash_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::ASTHash do
before :each do
diff --git a/spec/unit/parser/ast/boolean_operator_spec.rb b/spec/unit/parser/ast/boolean_operator_spec.rb
index 10e987e31..529946694 100755
--- a/spec/unit/parser/ast/boolean_operator_spec.rb
+++ b/spec/unit/parser/ast/boolean_operator_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::BooleanOperator do
diff --git a/spec/unit/parser/ast/casestatement_spec.rb b/spec/unit/parser/ast/casestatement_spec.rb
index 4d79e54cb..a77c04c43 100755
--- a/spec/unit/parser/ast/casestatement_spec.rb
+++ b/spec/unit/parser/ast/casestatement_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::CaseStatement do
before :each do
diff --git a/spec/unit/parser/ast/collection_spec.rb b/spec/unit/parser/ast/collection_spec.rb
index 392a2c0f0..a495bca15 100755
--- a/spec/unit/parser/ast/collection_spec.rb
+++ b/spec/unit/parser/ast/collection_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::Collection do
before :each do
diff --git a/spec/unit/parser/ast/collexpr_spec.rb b/spec/unit/parser/ast/collexpr_spec.rb
index 01276dfb3..04ce69cd3 100755
--- a/spec/unit/parser/ast/collexpr_spec.rb
+++ b/spec/unit/parser/ast/collexpr_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::CollExpr do
diff --git a/spec/unit/parser/ast/comparison_operator_spec.rb b/spec/unit/parser/ast/comparison_operator_spec.rb
index 931f936df..03c9069cb 100755
--- a/spec/unit/parser/ast/comparison_operator_spec.rb
+++ b/spec/unit/parser/ast/comparison_operator_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::ComparisonOperator do
before :each do
diff --git a/spec/unit/parser/ast/definition_spec.rb b/spec/unit/parser/ast/definition_spec.rb
index b7b2c851c..e7f55d258 100644
--- a/spec/unit/parser/ast/definition_spec.rb
+++ b/spec/unit/parser/ast/definition_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::Definition do
it "should make its context available through an accessor" do
diff --git a/spec/unit/parser/ast/function_spec.rb b/spec/unit/parser/ast/function_spec.rb
index 38e344157..cd4b0f94e 100644
--- a/spec/unit/parser/ast/function_spec.rb
+++ b/spec/unit/parser/ast/function_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::Function do
before :each do
diff --git a/spec/unit/parser/ast/hostclass_spec.rb b/spec/unit/parser/ast/hostclass_spec.rb
index b22eba98b..390490788 100644
--- a/spec/unit/parser/ast/hostclass_spec.rb
+++ b/spec/unit/parser/ast/hostclass_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::Hostclass do
def ast
diff --git a/spec/unit/parser/ast/ifstatement_spec.rb b/spec/unit/parser/ast/ifstatement_spec.rb
index 2a9e1e37b..6a2fed22c 100755
--- a/spec/unit/parser/ast/ifstatement_spec.rb
+++ b/spec/unit/parser/ast/ifstatement_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::IfStatement do
before :each do
diff --git a/spec/unit/parser/ast/in_operator_spec.rb b/spec/unit/parser/ast/in_operator_spec.rb
index aebe442ab..08c01582e 100644
--- a/spec/unit/parser/ast/in_operator_spec.rb
+++ b/spec/unit/parser/ast/in_operator_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
require 'puppet/parser/ast/in_operator'
diff --git a/spec/unit/parser/ast/leaf_spec.rb b/spec/unit/parser/ast/leaf_spec.rb
index a19c24115..2119a27a8 100755
--- a/spec/unit/parser/ast/leaf_spec.rb
+++ b/spec/unit/parser/ast/leaf_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::Leaf do
before :each do
diff --git a/spec/unit/parser/ast/match_operator_spec.rb b/spec/unit/parser/ast/match_operator_spec.rb
index d6e998751..f2a68b676 100755
--- a/spec/unit/parser/ast/match_operator_spec.rb
+++ b/spec/unit/parser/ast/match_operator_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::MatchOperator do
before :each do
diff --git a/spec/unit/parser/ast/minus_spec.rb b/spec/unit/parser/ast/minus_spec.rb
index 108c8812e..339087e80 100755
--- a/spec/unit/parser/ast/minus_spec.rb
+++ b/spec/unit/parser/ast/minus_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::Minus do
before :each do
diff --git a/spec/unit/parser/ast/node_spec.rb b/spec/unit/parser/ast/node_spec.rb
index 3e8017de0..c4e20ca67 100644
--- a/spec/unit/parser/ast/node_spec.rb
+++ b/spec/unit/parser/ast/node_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::Node do
describe "when instantiated" do
diff --git a/spec/unit/parser/ast/nop_spec.rb b/spec/unit/parser/ast/nop_spec.rb
index 3e493197a..3fa2fc0ee 100755
--- a/spec/unit/parser/ast/nop_spec.rb
+++ b/spec/unit/parser/ast/nop_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::Nop do
diff --git a/spec/unit/parser/ast/not_spec.rb b/spec/unit/parser/ast/not_spec.rb
index 2ef6e0689..31a425132 100755
--- a/spec/unit/parser/ast/not_spec.rb
+++ b/spec/unit/parser/ast/not_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::Not do
before :each do
diff --git a/spec/unit/parser/ast/relationship_spec.rb b/spec/unit/parser/ast/relationship_spec.rb
index 2a0f658df..d8bc3a535 100644
--- a/spec/unit/parser/ast/relationship_spec.rb
+++ b/spec/unit/parser/ast/relationship_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::Relationship do
before do
diff --git a/spec/unit/parser/ast/resource_defaults_spec.rb b/spec/unit/parser/ast/resource_defaults_spec.rb
index 7843fd9a9..36eb8df5f 100755
--- a/spec/unit/parser/ast/resource_defaults_spec.rb
+++ b/spec/unit/parser/ast/resource_defaults_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::ResourceDefaults do
diff --git a/spec/unit/parser/ast/resource_override_spec.rb b/spec/unit/parser/ast/resource_override_spec.rb
index 637ab41fc..7ca3a7e8c 100755
--- a/spec/unit/parser/ast/resource_override_spec.rb
+++ b/spec/unit/parser/ast/resource_override_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::ResourceOverride do
diff --git a/spec/unit/parser/ast/resource_reference_spec.rb b/spec/unit/parser/ast/resource_reference_spec.rb
index 93419d963..492c25490 100755
--- a/spec/unit/parser/ast/resource_reference_spec.rb
+++ b/spec/unit/parser/ast/resource_reference_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::ResourceReference do
diff --git a/spec/unit/parser/ast/resource_spec.rb b/spec/unit/parser/ast/resource_spec.rb
index 3f7fa229a..b00fee587 100755
--- a/spec/unit/parser/ast/resource_spec.rb
+++ b/spec/unit/parser/ast/resource_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::Resource do
ast = Puppet::Parser::AST
diff --git a/spec/unit/parser/ast/selector_spec.rb b/spec/unit/parser/ast/selector_spec.rb
index 42898475f..4c13aa7ba 100755
--- a/spec/unit/parser/ast/selector_spec.rb
+++ b/spec/unit/parser/ast/selector_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::Selector do
before :each do
diff --git a/spec/unit/parser/ast/vardef_spec.rb b/spec/unit/parser/ast/vardef_spec.rb
index a90010f5a..9c8b77905 100755
--- a/spec/unit/parser/ast/vardef_spec.rb
+++ b/spec/unit/parser/ast/vardef_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe Puppet::Parser::AST::VarDef do
before :each do
diff --git a/spec/unit/parser/ast_spec.rb b/spec/unit/parser/ast_spec.rb
index 29dce2b9c..cdfb51869 100644
--- a/spec/unit/parser/ast_spec.rb
+++ b/spec/unit/parser/ast_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/parser/ast'
diff --git a/spec/unit/parser/collector_spec.rb b/spec/unit/parser/collector_spec.rb
index 908cda63a..100a04daf 100755
--- a/spec/unit/parser/collector_spec.rb
+++ b/spec/unit/parser/collector_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/rails'
require 'puppet/parser/collector'
@@ -263,9 +263,7 @@ describe Puppet::Parser::Collector, "when collecting virtual and catalog resourc
end
end
-describe Puppet::Parser::Collector, "when collecting exported resources" do
- confine "Cannot test Rails integration without ActiveRecord" => Puppet.features.rails?
-
+describe Puppet::Parser::Collector, "when collecting exported resources", :if => Puppet.features.rails? do
before do
@compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
@scope = Puppet::Parser::Scope.new :compiler => @compiler
@@ -469,9 +467,7 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
end
end
-describe Puppet::Parser::Collector, "when building its ActiveRecord query for collecting exported resources" do
- confine "Cannot test Rails integration without ActiveRecord" => Puppet.features.rails?
-
+describe Puppet::Parser::Collector, "when building its ActiveRecord query for collecting exported resources", :if => Puppet.features.rails? do
before do
@scope = stub 'scope', :host => "myhost", :debug => nil
@compiler = mock 'compile'
diff --git a/spec/unit/parser/compiler_spec.rb b/spec/unit/parser/compiler_spec.rb
index 95f3853e2..18f9a93b6 100755
--- a/spec/unit/parser/compiler_spec.rb
+++ b/spec/unit/parser/compiler_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
class CompilerTestResource
attr_accessor :builtin, :virtual, :evaluated, :type, :title
@@ -105,8 +105,15 @@ describe Puppet::Parser::Compiler do
node.classes = %w{foo bar}
compiler = Puppet::Parser::Compiler.new(node)
- compiler.classlist.should include("foo")
- compiler.classlist.should include("bar")
+ compiler.classlist.should =~ ['foo', 'bar']
+ end
+
+ it "should transform node class hashes into a class list" do
+ node = Puppet::Node.new("mynode")
+ node.classes = {'foo'=>{'one'=>'1'}, 'bar'=>{'two'=>'2'}}
+ compiler = Puppet::Parser::Compiler.new(node)
+
+ compiler.classlist.should =~ ['foo', 'bar']
end
it "should add a 'main' stage to the catalog" do
@@ -185,6 +192,14 @@ describe Puppet::Parser::Compiler do
@compiler.class.publicize_methods(:evaluate_node_classes) { @compiler.evaluate_node_classes }
end
+ it "should evaluate any parameterized classes named in the node" do
+ classes = {'foo'=>{'1'=>'one'}, 'bar'=>{'2'=>'two'}}
+ @node.stubs(:classes).returns(classes)
+ @compiler.expects(:evaluate_classes).with(classes, @compiler.topscope)
+ @compiler.compile
+ end
+
+
it "should evaluate the main class if it exists" do
compile_stub(:evaluate_main)
main_class = @known_resource_types.add Puppet::Resource::Type.new(:hostclass, "")
@@ -532,7 +547,7 @@ describe Puppet::Parser::Compiler do
@compiler.add_collection(coll)
- lambda { @compiler.compile }.should raise_error(Puppet::ParseError)
+ lambda { @compiler.compile }.should raise_error Puppet::ParseError, 'Failed to realize virtual resources something'
end
it "should fail when there are unevaluated resource collections that refer to multiple specific resources" do
@@ -541,7 +556,7 @@ describe Puppet::Parser::Compiler do
@compiler.add_collection(coll)
- lambda { @compiler.compile }.should raise_error(Puppet::ParseError)
+ lambda { @compiler.compile }.should raise_error Puppet::ParseError, 'Failed to realize virtual resources one, two'
end
end
@@ -566,6 +581,14 @@ describe Puppet::Parser::Compiler do
@scope.expects(:find_hostclass).with("notfound").returns(nil)
@compiler.evaluate_classes(%w{notfound}, @scope)
end
+ # I wish it would fail
+ it "should log when it can't find class" do
+ klasses = {'foo'=>nil}
+ @node.classes = klasses
+ @compiler.topscope.stubs(:find_hostclass).with('foo').returns(nil)
+ Puppet.expects(:info).with('Could not find class foo for testnode')
+ @compiler.compile
+ end
end
describe "when evaluating found classes" do
@@ -586,6 +609,68 @@ describe Puppet::Parser::Compiler do
@compiler.evaluate_classes(%w{myclass}, @scope)
end
+ it "should ensure each node class hash is in catalog and have appropriate parameters" do
+ klasses = {'foo'=>{'1'=>'one'}, 'bar::foo'=>{'2'=>'two'}, 'bar'=>{'1'=> [1,2,3], '2'=>{'foo'=>'bar'}}}
+ @node.classes = klasses
+ ast_obj = Puppet::Parser::AST::String.new(:value => 'foo')
+ klasses.each do |name, params|
+ klass = Puppet::Resource::Type.new(:hostclass, name, :arguments => {'1' => ast_obj, '2' => ast_obj})
+ @compiler.topscope.known_resource_types.add klass
+ end
+ catalog = @compiler.compile
+ catalog.classes.should =~ ['foo', 'bar::foo', 'settings', 'bar']
+
+ r1 = catalog.resources.detect {|r| r.title == 'Foo' }
+ r1.to_hash.should == {:'1' => 'one', :'2' => 'foo'}
+ r1.tags. should =~ ['class', 'foo']
+
+ r2 = catalog.resources.detect {|r| r.title == 'Bar::Foo' }
+ r2.to_hash.should == {:'1' => 'foo', :'2' => 'two'}
+ r2.tags.should =~ ['bar::foo', 'class', 'bar', 'foo']
+
+ r2 = catalog.resources.detect {|r| r.title == 'Bar' }
+ r2.to_hash.should == {:'1' => [1,2,3], :'2' => {'foo'=>'bar'}}
+ r2.tags.should =~ ['class', 'bar']
+ end
+
+ it "should ensure each node class is in catalog and has appropriate tags" do
+ klasses = ['bar::foo']
+ @node.classes = klasses
+ ast_obj = Puppet::Parser::AST::String.new(:value => 'foo')
+ klasses.each do |name|
+ klass = Puppet::Resource::Type.new(:hostclass, name, :arguments => {'1' => ast_obj, '2' => ast_obj})
+ @compiler.topscope.known_resource_types.add klass
+ end
+ catalog = @compiler.compile
+
+ r2 = catalog.resources.detect {|r| r.title == 'Bar::Foo' }
+ r2.tags.should =~ ['bar::foo', 'class', 'bar', 'foo']
+ end
+
+ it "should fail if required parameters are missing" do
+ klass = {'foo'=>{'1'=>'one'}}
+ @node.classes = klass
+ klass = Puppet::Resource::Type.new(:hostclass, 'foo', :arguments => {'1' => nil, '2' => nil})
+ @compiler.topscope.known_resource_types.add klass
+ lambda { @compiler.compile }.should raise_error Puppet::ParseError, "Must pass 2 to Class[Foo]"
+ end
+
+ it "should fail if invalid parameters are passed" do
+ klass = {'foo'=>{'3'=>'one'}}
+ @node.classes = klass
+ klass = Puppet::Resource::Type.new(:hostclass, 'foo', :arguments => {'1' => nil, '2' => nil})
+ @compiler.topscope.known_resource_types.add klass
+ lambda { @compiler.compile }.should raise_error Puppet::ParseError, "Invalid parameter 3"
+ end
+
+ it "should ensure class is in catalog without params" do
+ @node.classes = klasses = {'foo'=>nil}
+ foo = Puppet::Resource::Type.new(:hostclass, 'foo')
+ @compiler.topscope.known_resource_types.add foo
+ catalog = @compiler.compile
+ catalog.classes.should include 'foo'
+ end
+
it "should not evaluate the resources created for found classes unless asked" do
@compiler.catalog.stubs(:tag)
@@ -759,7 +844,7 @@ describe Puppet::Parser::Compiler do
it "should fail if the compile is finished and resource overrides have not been applied" do
@compiler.add_override(@override)
- lambda { @compiler.compile }.should raise_error(Puppet::ParseError)
+ lambda { @compiler.compile }.should raise_error Puppet::ParseError, 'Could not find resource(s) File[/foo] for overriding'
end
end
end
diff --git a/spec/unit/parser/files_spec.rb b/spec/unit/parser/files_spec.rb
index 3eb0db07e..525c83697 100644
--- a/spec/unit/parser/files_spec.rb
+++ b/spec/unit/parser/files_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/parser/files'
diff --git a/spec/unit/parser/functions/defined_spec.rb b/spec/unit/parser/functions/defined_spec.rb
index cf3f66e17..0dd1dadb8 100755
--- a/spec/unit/parser/functions/defined_spec.rb
+++ b/spec/unit/parser/functions/defined_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the 'defined' function" do
diff --git a/spec/unit/parser/functions/extlookup_spec.rb b/spec/unit/parser/functions/extlookup_spec.rb
index a3dcaa742..a476dc844 100755
--- a/spec/unit/parser/functions/extlookup_spec.rb
+++ b/spec/unit/parser/functions/extlookup_spec.rb
@@ -1,6 +1,6 @@
#! /usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
require 'tempfile'
describe "the extlookup function" do
diff --git a/spec/unit/parser/functions/fqdn_rand_spec.rb b/spec/unit/parser/functions/fqdn_rand_spec.rb
index 81c12c6a7..151ebac9a 100644
--- a/spec/unit/parser/functions/fqdn_rand_spec.rb
+++ b/spec/unit/parser/functions/fqdn_rand_spec.rb
@@ -1,6 +1,6 @@
#! /usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the fqdn_rand function" do
diff --git a/spec/unit/parser/functions/generate_spec.rb b/spec/unit/parser/functions/generate_spec.rb
index 27aabe261..12f454210 100755
--- a/spec/unit/parser/functions/generate_spec.rb
+++ b/spec/unit/parser/functions/generate_spec.rb
@@ -1,6 +1,6 @@
#! /usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the generate function" do
diff --git a/spec/unit/parser/functions/include_spec.rb b/spec/unit/parser/functions/include_spec.rb
index 4f609b055..67227e7d9 100644
--- a/spec/unit/parser/functions/include_spec.rb
+++ b/spec/unit/parser/functions/include_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the 'include' function" do
diff --git a/spec/unit/parser/functions/inline_template_spec.rb b/spec/unit/parser/functions/inline_template_spec.rb
index 62f389e5d..36d53778d 100755
--- a/spec/unit/parser/functions/inline_template_spec.rb
+++ b/spec/unit/parser/functions/inline_template_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the inline_template function" do
diff --git a/spec/unit/parser/functions/realize_spec.rb b/spec/unit/parser/functions/realize_spec.rb
index 82f4fa251..899f69b01 100755
--- a/spec/unit/parser/functions/realize_spec.rb
+++ b/spec/unit/parser/functions/realize_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the realize function" do
diff --git a/spec/unit/parser/functions/regsubst_spec.rb b/spec/unit/parser/functions/regsubst_spec.rb
index 47126dd7a..09aa92d28 100755
--- a/spec/unit/parser/functions/regsubst_spec.rb
+++ b/spec/unit/parser/functions/regsubst_spec.rb
@@ -1,6 +1,6 @@
#! /usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the regsubst function" do
diff --git a/spec/unit/parser/functions/require_spec.rb b/spec/unit/parser/functions/require_spec.rb
index 49c4bbf74..4afbd5a63 100755
--- a/spec/unit/parser/functions/require_spec.rb
+++ b/spec/unit/parser/functions/require_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the require function" do
diff --git a/spec/unit/parser/functions/shellquote_spec.rb b/spec/unit/parser/functions/shellquote_spec.rb
index 46b9f8d10..c8b0d650d 100755
--- a/spec/unit/parser/functions/shellquote_spec.rb
+++ b/spec/unit/parser/functions/shellquote_spec.rb
@@ -1,6 +1,6 @@
#! /usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the shellquote function" do
diff --git a/spec/unit/parser/functions/split_spec.rb b/spec/unit/parser/functions/split_spec.rb
index a1c83bb0f..39710003b 100755
--- a/spec/unit/parser/functions/split_spec.rb
+++ b/spec/unit/parser/functions/split_spec.rb
@@ -1,6 +1,6 @@
#! /usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the split function" do
diff --git a/spec/unit/parser/functions/sprintf_spec.rb b/spec/unit/parser/functions/sprintf_spec.rb
index 01545a879..4f29012b3 100755
--- a/spec/unit/parser/functions/sprintf_spec.rb
+++ b/spec/unit/parser/functions/sprintf_spec.rb
@@ -1,6 +1,6 @@
#! /usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the sprintf function" do
diff --git a/spec/unit/parser/functions/tag_spec.rb b/spec/unit/parser/functions/tag_spec.rb
index dac134134..e9b5122c7 100755
--- a/spec/unit/parser/functions/tag_spec.rb
+++ b/spec/unit/parser/functions/tag_spec.rb
@@ -1,6 +1,6 @@
#! /usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the 'tag' function" do
diff --git a/spec/unit/parser/functions/template_spec.rb b/spec/unit/parser/functions/template_spec.rb
index 096b0598e..9dd5cc947 100755
--- a/spec/unit/parser/functions/template_spec.rb
+++ b/spec/unit/parser/functions/template_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the template function" do
diff --git a/spec/unit/parser/functions/versioncmp_spec.rb b/spec/unit/parser/functions/versioncmp_spec.rb
index 380c6307a..2bc7be801 100755
--- a/spec/unit/parser/functions/versioncmp_spec.rb
+++ b/spec/unit/parser/functions/versioncmp_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
describe "the versioncmp function" do
diff --git a/spec/unit/parser/functions_spec.rb b/spec/unit/parser/functions_spec.rb
index 18aee4b65..51e52faee 100644
--- a/spec/unit/parser/functions_spec.rb
+++ b/spec/unit/parser/functions_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe Puppet::Parser::Functions do
diff --git a/spec/unit/parser/lexer_spec.rb b/spec/unit/parser/lexer_spec.rb
index d52add399..58978ff03 100755
--- a/spec/unit/parser/lexer_spec.rb
+++ b/spec/unit/parser/lexer_spec.rb
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/parser/lexer'
# This is a special matcher to match easily lexer output
-Spec::Matchers.define :be_like do |*expected|
+RSpec::Matchers.define :be_like do |*expected|
match do |actual|
expected.zip(actual).all? { |e,a| !e or a[0] == e or (e.is_a? Array and a[0] == e[0] and (a[1] == e[1] or (a[1].is_a?(Hash) and a[1][:value] == e[1]))) }
end
@@ -651,7 +651,8 @@ describe "Puppet::Parser::Lexer in the old tests" do
end
end
-require 'puppettest/support/utils'
+require File.dirname(__FILE__) + '/../../../test/lib/puppettest'
+require File.dirname(__FILE__) + '/../../../test/lib/puppettest/support/utils'
describe "Puppet::Parser::Lexer in the old tests when lexing example files" do
extend PuppetTest::Support::Utils
textfiles do |file|
diff --git a/spec/unit/parser/parser_spec.rb b/spec/unit/parser/parser_spec.rb
index ab43194e9..f5df3041c 100755
--- a/spec/unit/parser/parser_spec.rb
+++ b/spec/unit/parser/parser_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe Puppet::Parser do
diff --git a/spec/unit/parser/relationship_spec.rb b/spec/unit/parser/relationship_spec.rb
index 57f1a772b..883a38d11 100644
--- a/spec/unit/parser/relationship_spec.rb
+++ b/spec/unit/parser/relationship_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/parser/relationship'
diff --git a/spec/unit/parser/resource_spec.rb b/spec/unit/parser/resource_spec.rb
index dae22fcaa..73c4412dd 100755
--- a/spec/unit/parser/resource_spec.rb
+++ b/spec/unit/parser/resource_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
# LAK: FIXME This is just new tests for resources; I have
# not moved all tests over yet.
diff --git a/spec/unit/parser/scope_spec.rb b/spec/unit/parser/scope_spec.rb
index 2e390a53b..32a87f1f4 100755
--- a/spec/unit/parser/scope_spec.rb
+++ b/spec/unit/parser/scope_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe Puppet::Parser::Scope do
before :each do
diff --git a/spec/unit/parser/templatewrapper_spec.rb b/spec/unit/parser/templatewrapper_spec.rb
index 68d90a1cc..aab169348 100755
--- a/spec/unit/parser/templatewrapper_spec.rb
+++ b/spec/unit/parser/templatewrapper_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/parser/templatewrapper'
describe Puppet::Parser::TemplateWrapper do
diff --git a/spec/unit/parser/type_loader_spec.rb b/spec/unit/parser/type_loader_spec.rb
index cfa68871d..bd41adfb6 100644
--- a/spec/unit/parser/type_loader_spec.rb
+++ b/spec/unit/parser/type_loader_spec.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'puppet/parser/type_loader'
require 'puppet_spec/files'