summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-06 19:24:25 -0500
committerLuke Kanies <luke@madstop.com>2007-09-06 19:24:25 -0500
commit4104bd3ee9fa146b49aa446fbf4cc3edcdf0974d (patch)
treedfa1a147f8949c4fd09484979714397c4248f666 /spec
parentb7f42441b91c921cd31f3d8c7875ce98bdedf786 (diff)
downloadpuppet-4104bd3ee9fa146b49aa446fbf4cc3edcdf0974d.tar.gz
puppet-4104bd3ee9fa146b49aa446fbf4cc3edcdf0974d.tar.xz
puppet-4104bd3ee9fa146b49aa446fbf4cc3edcdf0974d.zip
Fixing #807. The exception handling should more closely resemble how it used to be done.
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/node/configuration.rb14
-rwxr-xr-xspec/unit/parser/interpreter.rb6
2 files changed, 16 insertions, 4 deletions
diff --git a/spec/unit/node/configuration.rb b/spec/unit/node/configuration.rb
index 90bc56460..4429fe3a3 100755
--- a/spec/unit/node/configuration.rb
+++ b/spec/unit/node/configuration.rb
@@ -54,6 +54,16 @@ end
describe Puppet::Node::Configuration, " when extracting transobjects" do
+ def mkscope
+ @parser = Puppet::Parser::Parser.new :Code => ""
+ @node = Puppet::Node.new("mynode")
+ @compile = Puppet::Parser::Compile.new(@node, @parser)
+
+ # XXX This is ridiculous.
+ @compile.send(:evaluate_main)
+ @scope = @compile.topscope
+ end
+
def mkresource(type, name)
Puppet::Parser::Resource.new(:type => type, :title => name, :source => @source, :scope => @scope)
end
@@ -62,7 +72,7 @@ describe Puppet::Node::Configuration, " when extracting transobjects" do
it "should transform the resource graph into a tree of TransBuckets and TransObjects" do
config = Puppet::Node::Configuration.new("mynode")
- @scope = mock 'scope'
+ @scope = mkscope
@source = mock 'source'
defined = mkresource("class", :main)
@@ -83,7 +93,7 @@ describe Puppet::Node::Configuration, " when extracting transobjects" do
it "should transform arbitrarily deep graphs into isomorphic trees" do
config = Puppet::Node::Configuration.new("mynode")
- @scope = mock 'scope'
+ @scope = mkscope
@scope.stubs(:tags).returns([])
@source = mock 'source'
diff --git a/spec/unit/parser/interpreter.rb b/spec/unit/parser/interpreter.rb
index ebb7d4cbf..c0f9d54b3 100755
--- a/spec/unit/parser/interpreter.rb
+++ b/spec/unit/parser/interpreter.rb
@@ -67,7 +67,7 @@ describe Puppet::Parser::Interpreter, " when creating parser instances" do
it "should return nothing when new parsers fail" do
Puppet::Parser::Parser.expects(:new).with(:environment => :myenv).raises(ArgumentError)
- @interp.send(:create_parser, :myenv).should be_nil
+ proc { @interp.send(:create_parser, :myenv) }.should raise_error(Puppet::Error)
end
it "should create parsers with environment-appropriate manifests" do
@@ -83,11 +83,13 @@ describe Puppet::Parser::Interpreter, " when creating parser instances" do
parser1 = mock 'parser1'
Puppet::Parser::Parser.expects(:new).with(:environment => :env1).returns(parser1)
parser1.expects(:file=).with("/t/env1.pp")
+ parser1.expects(:parse)
@interp.send(:create_parser, :env1)
parser2 = mock 'parser2'
Puppet::Parser::Parser.expects(:new).with(:environment => :env2).returns(parser2)
parser2.expects(:file=).with("/t/env2.pp")
+ parser2.expects(:parse)
@interp.send(:create_parser, :env2)
end
end
@@ -100,7 +102,7 @@ describe Puppet::Parser::Interpreter, " when managing parser instances" do
it "it should an exception when nothing is there and nil is returned" do
@interp.expects(:create_parser).with(:myenv).returns(nil)
- lambda { @interp.send(:parser, :myenv) }.should raise_error(Puppet::Error)
+ @interp.send(:parser, :myenv).should be_nil
end
it "should create and return a new parser and use the same parser when the parser does not need reparsing" do