diff options
| author | Luke Kanies <luke@madstop.com> | 2007-10-05 11:46:35 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-10-05 11:46:35 -0500 |
| commit | 9c58c476c2ffcf9613f14e5881b1177f01d413a7 (patch) | |
| tree | 8791274ce754f486f039ba942e3a5d3d9939df3e /spec/unit/parser | |
| parent | d35cd947c82ba9da8ec798100a3c710c34492521 (diff) | |
Adding a :code setting for specifying code to run
instead of a manifest, and removing all of the ambiguity
around whether an interpreter gets its own file specified
or uses the central setting.
Most of the changes are around fixing existing tests to use this new system.
Diffstat (limited to 'spec/unit/parser')
| -rwxr-xr-x | spec/unit/parser/interpreter.rb | 44 |
1 files changed, 7 insertions, 37 deletions
diff --git a/spec/unit/parser/interpreter.rb b/spec/unit/parser/interpreter.rb index fbf3bdb23..782b30cc7 100755 --- a/spec/unit/parser/interpreter.rb +++ b/spec/unit/parser/interpreter.rb @@ -2,55 +2,25 @@ require File.dirname(__FILE__) + '/../../spec_helper' -describe Puppet::Parser::Interpreter, " when initializing" do - it "should default to neither code nor file" do - interp = Puppet::Parser::Interpreter.new - interp.code.should be_nil - interp.file.should be_nil - end - - it "should set the code to parse" do - interp = Puppet::Parser::Interpreter.new :Code => :code - interp.code.should equal(:code) - end - - it "should set the file to parse" do - interp = Puppet::Parser::Interpreter.new :Manifest => :file - interp.file.should equal(:file) - end - - it "should set code and ignore manifest when both are present" do - interp = Puppet::Parser::Interpreter.new :Code => :code, :Manifest => :file - interp.code.should equal(:code) - interp.file.should be_nil - end -end - describe Puppet::Parser::Interpreter, " when creating parser instances" do before do @interp = Puppet::Parser::Interpreter.new @parser = mock('parser') end - it "should create a parser with code passed in at initialization time" do - @interp.code = :some_code - @parser.expects(:string=).with(:some_code) + it "should create a parser with code if there is code defined in the :code setting" do + Puppet.settings.stubs(:value).with(:code, :myenv).returns("mycode") + @parser.expects(:string=).with("mycode") @parser.expects(:parse) Puppet::Parser::Parser.expects(:new).with(:environment => :myenv).returns(@parser) @interp.send(:create_parser, :myenv).object_id.should equal(@parser.object_id) end - it "should create a parser with a file passed in at initialization time" do - @interp.file = :a_file - @parser.expects(:file=).with(:a_file) - @parser.expects(:parse) - Puppet::Parser::Parser.expects(:new).with(:environment => :myenv).returns(@parser) - @interp.send(:create_parser, :myenv).should equal(@parser) - end - - it "should create a parser with the main manifest when passed neither code nor file" do + it "should create a parser with the main manifest when the code setting is an empty string" do + Puppet.settings.stubs(:value).with(:code, :myenv).returns("") + Puppet.settings.stubs(:value).with(:manifest, :myenv).returns("/my/file") @parser.expects(:parse) - @parser.expects(:file=).with(Puppet[:manifest]) + @parser.expects(:file=).with("/my/file") Puppet::Parser::Parser.expects(:new).with(:environment => :myenv).returns(@parser) @interp.send(:create_parser, :myenv).should equal(@parser) end |
