diff options
| author | Paul Berry <paul@puppetlabs.com> | 2010-09-07 18:01:42 -0700 |
|---|---|---|
| committer | Paul Berry <paul@puppetlabs.com> | 2010-09-07 18:01:42 -0700 |
| commit | ce9bf1edcaac4901de6e0a7da413d1742d216eb0 (patch) | |
| tree | e0ec052bf1d6b33ec3d8a90970ba10206c06d53c /spec | |
| parent | 25048ecc40db746f7e88bb6c5e1fc4f2c0150a4f (diff) | |
| download | puppet-ce9bf1edcaac4901de6e0a7da413d1742d216eb0.tar.gz puppet-ce9bf1edcaac4901de6e0a7da413d1742d216eb0.tar.xz puppet-ce9bf1edcaac4901de6e0a7da413d1742d216eb0.zip | |
Modified the error message that is generated when a class, definition,
or node occurs in a conditional construct so that it contains the
proper line number.
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/integration/parser/compiler_spec.rb | 22 | ||||
| -rw-r--r-- | spec/unit/parser/ast/definition_spec.rb | 5 | ||||
| -rw-r--r-- | spec/unit/parser/ast/node_spec.rb | 5 |
3 files changed, 23 insertions, 9 deletions
diff --git a/spec/integration/parser/compiler_spec.rb b/spec/integration/parser/compiler_spec.rb index ffff4d845..df310ac07 100755 --- a/spec/integration/parser/compiler_spec.rb +++ b/spec/integration/parser/compiler_spec.rb @@ -81,15 +81,23 @@ describe Puppet::Parser::Compiler do Puppet::Parser::Compiler.compile(node).version.should == 2 end - it "should not allow classes inside evaluated conditional constructs" do - Puppet[:code] = <<-PP - if true { - class foo { + ['class', 'define', 'node'].each do |thing| + it "should not allow #{thing} inside evaluated conditional constructs" do + Puppet[:code] = <<-PP + if true { + #{thing} foo { + } + notify { decoy: } } - } - PP + PP - lambda { Puppet::Parser::Compiler.compile(Puppet::Node.new("mynode")) }.should raise_error(Puppet::Error) + begin + Puppet::Parser::Compiler.compile(Puppet::Node.new("mynode")) + raise "compilation should have raised Puppet::Error" + rescue Puppet::Error => e + e.message.should =~ /at line 2/ + end + end end it "should not allow classes inside unevaluated conditional constructs" do diff --git a/spec/unit/parser/ast/definition_spec.rb b/spec/unit/parser/ast/definition_spec.rb index 01ca068ad..b7b2c851c 100644 --- a/spec/unit/parser/ast/definition_spec.rb +++ b/spec/unit/parser/ast/definition_spec.rb @@ -3,6 +3,11 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe Puppet::Parser::AST::Definition do + it "should make its context available through an accessor" do + definition = Puppet::Parser::AST::Definition.new('foo', :line => 5) + definition.context.should == {:line => 5} + end + describe "when instantiated" do it "should create a definition with the proper type, name, context, and module name" do definition = Puppet::Parser::AST::Definition.new('foo', :line => 5) diff --git a/spec/unit/parser/ast/node_spec.rb b/spec/unit/parser/ast/node_spec.rb index 409e877f9..3e8017de0 100644 --- a/spec/unit/parser/ast/node_spec.rb +++ b/spec/unit/parser/ast/node_spec.rb @@ -4,9 +4,10 @@ require File.dirname(__FILE__) + '/../../../spec_helper' describe Puppet::Parser::AST::Node do describe "when instantiated" do - it "should make its names available through an accessor" do - node = Puppet::Parser::AST::Node.new(['foo', 'bar']) + it "should make its names and context available through accessors" do + node = Puppet::Parser::AST::Node.new(['foo', 'bar'], :line => 5) node.names.should == ['foo', 'bar'] + node.context.should == {:line => 5} end it "should create a node with the proper type, name, context, and module name" do |
