summaryrefslogtreecommitdiffstats
path: root/spec/unit/node
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2011-03-24 17:51:59 -0700
committerJesse Wolfe <jes5199@gmail.com>2011-03-25 15:20:39 -0700
commitdaaa048a8d8829ad509b4a456826cc8a33cf6444 (patch)
tree817971bd3c1a7e8383bc3243833b8d1367e768dc /spec/unit/node
parentc7f6e5ee743c061c020521651360bba240ae4519 (diff)
downloadpuppet-daaa048a8d8829ad509b4a456826cc8a33cf6444.tar.gz
puppet-daaa048a8d8829ad509b4a456826cc8a33cf6444.tar.xz
puppet-daaa048a8d8829ad509b4a456826cc8a33cf6444.zip
(#5477) Allow watch_file to watch non-existent files, especially site.pp
The watch_file mechanism would refuse to monitor paths to files that didn't exist. This patch makes it possible to watch a file that hasn't been created yet, so when it is created, you manifests will get reparsed. Paired-With: Max Martin <max@puppetlabs.com> Reviewed-By: Jacob Helwig <jacob@puppetlabs.com>
Diffstat (limited to 'spec/unit/node')
-rwxr-xr-xspec/unit/node/environment_spec.rb29
1 files changed, 13 insertions, 16 deletions
diff --git a/spec/unit/node/environment_spec.rb b/spec/unit/node/environment_spec.rb
index 153be5f60..05527e70f 100755
--- a/spec/unit/node/environment_spec.rb
+++ b/spec/unit/node/environment_spec.rb
@@ -6,6 +6,7 @@ require 'puppet/node/environment'
require 'puppet/util/execution'
describe Puppet::Node::Environment do
+ include PuppetSpec::Files
after do
Puppet::Node::Environment.clear
end
@@ -276,16 +277,11 @@ describe Puppet::Node::Environment do
describe "when performing initial import" do
before do
- @parser = stub 'parser', :file= => nil, :string => nil, :parse => nil
+ @parser = stub 'parser'
Puppet::Parser::Parser.stubs(:new).returns @parser
@env = Puppet::Node::Environment.new("env")
end
- it "should create a new parser instance" do
- Puppet::Parser::Parser.expects(:new).returns @parser
- @env.instance_eval { perform_initial_import }
- end
-
it "should set the parser's string to the 'code' setting and parse if code is available" do
Puppet.settings[:code] = "my code"
@parser.expects(:string=).with "my code"
@@ -294,25 +290,26 @@ describe Puppet::Node::Environment do
end
it "should set the parser's file to the 'manifest' setting and parse if no code is available and the manifest is available" do
- File.stubs(:expand_path).with("/my/file").returns "/my/file"
- File.expects(:exist?).with("/my/file").returns true
- Puppet.settings[:manifest] = "/my/file"
- @parser.expects(:file=).with "/my/file"
+ filename = tmpfile('myfile')
+ File.open(filename, 'w'){|f| }
+ Puppet.settings[:manifest] = filename
+ @parser.expects(:file=).with filename
@parser.expects(:parse)
@env.instance_eval { perform_initial_import }
end
- it "should not attempt to load a manifest if none is present" do
- File.stubs(:expand_path).with("/my/file").returns "/my/file"
- File.expects(:exist?).with("/my/file").returns false
- Puppet.settings[:manifest] = "/my/file"
- @parser.expects(:file=).never
- @parser.expects(:parse).never
+ it "should pass the manifest file to the parser even if it does not exist on disk" do
+ filename = tmpfile('myfile')
+ Puppet.settings[:code] = ""
+ Puppet.settings[:manifest] = filename
+ @parser.expects(:file=).with(filename).once
+ @parser.expects(:parse).once
@env.instance_eval { perform_initial_import }
end
it "should fail helpfully if there is an error importing" do
File.stubs(:exist?).returns true
+ @parser.expects(:file=).once
@parser.expects(:parse).raises ArgumentError
lambda { @env.instance_eval { perform_initial_import } }.should raise_error(Puppet::Error)
end